Write jpeg with header comment – boost generic image library (gil)

I had to hack the living daylights out of something today, and although I am not proud of it, needs must where the devil drives!

I was using the boost generic image library (gil) for managing some camera images and using jpeg_write_view() for saving them as JPEGs. A requirement emerged to insert a comment into the header of the saved images, but the gil does not support this out of the box.

The gil uses libjpeg for writing its JPEGs and adding a comment in libjped is as easy as calling jpeg_write_marker(). The problem was that the gil buries libjpeg calls under a few classes so I had to copy and paste some of this in order to redefine a new writer which supports comments.

Anyway I have included the extra code inline below, it adds a new helper function called jpeg_write_view_comment()

Use this new function like this:

Here is the extra code which I placed in a file called jpeg_writer_comment.h

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *