D
D
Denius (genius)2018-11-01 10:11:45
Java
Denius (genius), 2018-11-01 10:11:45

How to put text on photo in Java?

I need to put text on a photo.
There is an original photo (for example, a photo of mountains), I need to put text on it and save it.
Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
ivan19631224, 2018-11-01
@Conan_Doyle_SBINH

You can use the package javax.imageioand graphics API from the java standard libraries:

File file = new File("C:\\фото_гор.jpg");
BufferedImage image = ImageIO.read(file);
Graphics2D g = image.createGraphics();
g.setColor(Color.RED);
g.setFont(new Font("Courier New", Font.BOLD, 50));
g.drawString("Какой-то текст", 20, 50);
ImageIO.write(image, "jpg", new File(file.getParentFile(), "фото_гор_с_текстом.jpg"));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question