Ben Nadel
On User Experience (UX) Design, JavaScript, ColdFusion, Node.js, Life, and Love.
I am the chief technical officer at InVision App, Inc - a prototyping and collaboration platform for designers, built by designers. I also rock out in JavaScript and ColdFusion 24x7.
Meanwhile on Twitter
Loading latest tweet...
Ben Nadel at CFUNITED 2008 (Washington, D.C.) with: Simon Free

Embedding ZIP Files Inside JPG Files Using ColdFusion (Live Demo)

By Ben Nadel on
Tags: ColdFusion

Earlier this week, I posted a demonstration of how to use ColdFusion to programmatically create zip files and then embed those zip files secretly inside of JPG image files. I also demonstrated how to use ColdFusion to extract this hidden, embedded data from the resultant JPG file. In the comments to the blog post, Gary Fenton asked how to use the resultant file without using ColdFusion. On my machine, Windows XP, it's simply a matter of renaming the file extension. To make sure that we're all on the same page, I put together a quick little demo:


I can't say that this works on other versions of Windows, but XP handles it nicely.

Reader Comments

Thanks Ben. I believe you now. :-D I'll run the code locally to generate the merged jpeg. Maybe IE did something to the image when I right-clicked and saved it from your previous blog.

Reply to this Comment

It should be noted that the reason this kinda thing is possible is due to the way some file formats are structured.

JPEG (as well as the various MPEGs, including MP3s) allows junk data to be included with the file - any applications designed to read those files just ignore anything that's not part of a JPEG.

Similarly programs that handle ZIP files will ignore the JPEG portion - what appears to be junk to them.

In Windows you can get away with this sort of thing, just by using file extensions - if it's a .jpg, Windows will try to use your associated image application to read it; but if it's a .zip, it'll use your default compression app.

When it comes to systems that use the actual content to try to identify file types, this may not work so well.

Various Linux frontends (like gnome/KDE) for example will probably identify the first part of the file - an image - and open it using an image editor, even if the extension is .zip (I have yet to test this - probably won't get a chance to touch my Linux boxen in the near future)

Of course, if you choose to open the file using the specific application in question, it shouldn't be a problem.

I'd be interested to see what happens if you use two different file types which can be read by the one application - for example, concatenating a raw WAV file after an mp3 or something, and seeing how winamp/media player handles it (or jpg/png for a smaller test).


Reply to this Comment

Cool. I didn't know that it handled RAR files also. I'll have to see how much quicker it is that WinRAR.

Reply to this Comment


Looks cool. Anything in particular that I should know about it?


Thanks for pointing that - that's kind of cool. Maybe today :D

Reply to this Comment

@Ben: It's free? It doesn't nag you like winrar does? :) It's also open-source. I've seen mixed results between 7-Zip files (.7z) and Winrar (.rar), majority of the times 7-Zip won in the compression size. The max compression is still .zip (which 7-Zip still handles). Otherwise, it will un-rar, un-zip, un-7z, etc.

Reply to this Comment

Post A Comment

You — Get Out Of My Dreams, Get Into My Comments
Live in the Now
Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.