Jpeg comments

Perhapse not strongly game-related, I’m trying to modify the Exif headers in Jpeg images… that is I want to add comments into the file.

I already have a way of reading a input stream and modifying it, and then stream it into a outputstream. But this will create a new file, which i don’t want.

Isn’t there a way to simply open up a Jpeg file, add the comment, and then store it… without reading the whole file and creating a new file?

As far as I know –
No.

I made a program just to rename some images I had en masse, and all I could do was read in the .jpg and then rewrite it out as a completely new image with my chosen name. It was kind of slow and kind of a pain, but I could just leave the program running, go and do something else, then in 10 minutes or so I’d have a few hundred renamed images (this was for categorizing images on my camera and from my scanner, mostly).

It would have been much easier if I could have just modified each image, but I really don’t think that’s possible. If you edit and then save an image in Photoshop it often saves a copy and replaces the old one, so it seems to me this is undoable.

But if someone says otherwise, I will be very happy.

well if exif headers were fixed length you could use RandomAccessFile to read and manipulate just the headers. if it is some random-length string, then you are forced to update the rest of the file as well since you can’t just ‘insert’ bytes. (technically if you had access to the underlying filesystem, you could just update the file allocation tables)

Ok, thanks for your replies.