Reputation: 683
Is there a way to add JPEG comments ("COM" markers) to an existing JPEG image file using libjpeg?
It is certainly possible to do so by first decompressing an existing image to an in-memory buffer and then compressing the raw image again with jpeg_write_marker( ... JPEG_COM ... ) to add comments, and saving to disk. Unless there is a need to decompress first, doing this seems to be an overkill.
Upvotes: 3
Views: 4242
Reputation: 1
Someone may use JPEG Comment Editor created by Mwisoft. It automate adding / editing JPEG comments using Windows, instead of right-click JPEG file and click properties to manually add comments.
Upvotes: 0
Reputation: 400454
You can use jpeg_write_marker()
during the writing of the output file to write the comment after setting it up. Then, use jpeg_read_coefficients()
and jpeg_write_coefficients()
(in place of the ordinary jpeg_read_scanlines()
and jpeg_write_scanlines()
) to read and write the raw, compressed data without actually decompressing and recompressing it.
See the section "Really raw data: DCT coefficients" in the libjpeg documentation. Be sure to read all the caveats mentioned there.
Upvotes: 2