import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
public class Demo{
public static void main(String[] args) {
try {
File f1 = new File("1.jpg");
BufferedImage image = ImageIO.read(f1);
Graphics g = image.getGraphics();
g.setFont(new Font("Serif",Font.BOLD,70));
g.setColor(Color.red);
g.drawString("happy new year!", 100, 100);
File f2 = new File("copy.jpg");
ImageIO.write(image, "JPEG", f2);
} catch (IOException e) {
e.printStackTrace();
}
}
}
希望对你有所帮助