Jim's Depository

this code is not yet written

I’ve written jpegapp which can be used to remove, insert, and extract the application specific segments of a JPEG file. I used it to embed transparency information in JPEGs, but you can use it however you like, some things that come to mind:

  • Remove EXIF or other strange camera information from JPEGs that you publish.
  • Attach source annotations to images when your create them automatically.
  • Yank out some application’s data to analyze.

A PDF of the man page is attached to this article.

You can find the source code over at google code jpegapp. BSD licensed. Enjoy.


jpegapp.pdf 4474 bytes

I have written a program and some javascript to add alpha channels to JPEG images and render them correctly in modern browsers. 

The exposition requires some Javascript which femtoblogger does not allow, so I have documented the techniques on their own page: On adding alpha channels to JPEG images.

The code isn’t pretty yet, but it works.

I apologize for not testing on IE. The canvas based method should work with FlashCanvas per http://blog.jackadam.net/2010/alpha-jpegs/, but I don’t have the licenses to run the IE test images. (Wine will unpack the self extracting .EXE they insist on using as a shipping container, but VirtualBox has different emulated hardware from what the images expect and that leads to no network which cascades into avalanches of dialogs asking to download network drivers over the network that doesn’t exist and demands to register over the network with does not exist.)


boot.gif 43981 bytes
weird, it's working on FF2 but not on IE6, but it's probably a matter of your JS code rather than the amazing technique you discovered :
Line: 218
Character: 3
Code: 0
Error Message: Expected identifier, string or number


I realise you did this 2 years ago now, but this is really awesome. I'm a bit surprised there's not more attention drawn to:
  • adding transparency to the JPEG specification in a standards-based way and
  • your stop-gap solution.
This may certainly come in handy for some client one day, thank you for exploring this and developing tools for us to use even!

Just curious though, why are you using uncompressed PNGs for the alpha channel?  It would seem to me that embedding a grey-scale JPEG layer into the original JPEG would yield a much more compact solution and the benefits and pitfalls of lossfully compressing the alpha-channel should be very understood by the wielder of this solution.

Given the apparent intelligence reflected in your posts, it is obvious to me that you had already considered this, but yet you went with embedding a PNG into a JPEG.  Do you have a post somewhere that details your logic here?  If you're not interested in blogging about it, please drop a note at 'm' followed by 'j' followed by 'k' at sisuconsulting.com.  Many, many thanks in advance!