Answer the question
In order to leave comments, you need to log in
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
You can use the package javax.imageio
and 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 questionAsk a Question
731 491 924 answers to any question