One issue that came up when we were testing the original version of this software was that metadata was being kept in images that were created by the system. Small "slices" of the original images uploaded by players were passed along to subsequent players, for them to use in their own creations, and any existing EXIF thumbnail images in the original image file were accidentally also being passed along.
After some futzing around with ImageMagick http://www.imagemagick.org I eventually settled on using the jpegtran tools that come installed on just about every flavor of Linux. But I never gave up on a possible PerlMagick solution, and now I've finally stumbled upon the correct combination of incantations that allow you to create an image with no EXIF data. Since the documentation for ImageMagick is quite sparse, I thought I would record my discovery here.
I suspected that copying an image from one Image::Magick object to another would probably not copy the EXIF data, and it took me a while to stumble on the Composite() method which in fact works exactly as I suspected it would. Here's my code:
use Image::Magick; my($i) = Image::Magick->new(); my($j) = Image::Magick->new(); $i->Read('image-with-exif.jpg'); $j->Set('size', $i->Get('width').'x'.$i->Get('height')); $j->Read('NULL:white'); $resp = $j->Composite( image => $i, compose => Copy ); # you can check $resp for errors $j->Write('image-without-exif.jpg');A couple of things that might not be obvious to the ImageMagick novice:
$j->Read()
function call is needed to create an image in the $j
variable. Apparently you need to have some image in your destination variable to copy stuff onto. NULL:white
string is what's known in ImageMagick as a pseudo-image format. Other formats, useful for creating gradients, steganographic images, plasma backgrounds, etc. can be found in this page in the ImageMagick documentation: