views:

383

answers:

2

I am programmatically generating several sizes of thumbnails for images.

I need to preserve the color space of an image while removing all (other) EXIF information.

I am using imagick on PHP 5.3, but information on how to do this with any imagemagick API would be helpful.

I'm trying to prune the file size of my image thumbnails as much as possible, but the color space is necessary information or the client doesn't render the colors accurately enough.

A: 

Without knowing your exact use case and why you want to do this via php, I was wondering if you tried ExifTool from Phil Harvey? It allows you to add, modify, and delete the typical image metadata. You can edit individual images and whole image batches.

Tom
Thanks for the tip, I installed that app. I actually don't think the color profile is stored in the EXIF data, but rather as part of the image format. That said, the way that imagemagick interacts with EXIF data and color profiles are similar.
Kyle Wiens
A: 

To achieve this I used MagickStripImage() to remove all the extraneous data, then ran -convert [inputJPG] -profile [profile] [outputJPG] to add the sRGB profile again.

This worked for my purposes (as I'd already done profile conversion beforehand, so all my profiles are sRGB). I did try Tom's suggestion of using ExifTool (which is fantastic) but couldn't get it to strip out EXIF+XMP+IPTC and leave the profile intact.

Graham B