I’ve been looking for a simple tool to add a date/time stamp to some jpeg images. There are quite a lot of tools to do this but they all tend to cost money. I decided to make my own in Java. The actual process of loading a jpeg, adding a stamp and then saving it again is very simple. The below snippet will do the job.
BufferedImage bi = ImageIO.read(sourceFile); Graphics2D graphics = bi.createGraphics(); Font font = new Font("ARIAL", Font.PLAIN, 20); graphics.setFont(font); graphics.drawString(stamp, 50, 50); bi.flush(); ImageIO.write(bi, "jpg", targetFile);
I added some options (you can change font size, position, colour) to meet my needs. You can download it for free from https://www.reviewmylife.co.uk/blog/2008/07/03/photostamper-utility-with-java-source/. It is very basic – command line only – but does the job well enough. The Java source code and Eclipse project files are also available for download.