I tried the following function which I wrote:
Code: Select all
function sanitizeExif($im, $whitelist=array()) {
$alwaysPreserve = array('Copyright',
'ColorSpace',
'Orientation',
'ExifImageLength',
'ExifImageWidth',
'ExifOffset',
'ExifVersion',
'thumbnail:ResolutionUnit',
'thumbnail:XResolution',
'thumbnail:YResolution',
'XResolution',
'YResolution'
);
$saveExif = array_merge($whitelist, $alwaysPreserve);
$exifArray = $im->getImageProperties("exif:*");
foreach($exifArray as $name => $property) {
$test = preg_replace('/^exif:/', '', $name);
if (! in_array($test, $saveExif)) {
$im->setImageProperty($name, '');
}
}
}
However when writing the image to file, the old exif data I tried to remove is still there.
I thought maybe there might be some kind of a commit changes function but I can't find one.
According to
http://www.php.net/manual/en/imagick.se ... operty.php
it should work. What am I doing wrong?
php-5.5.14-1.fc20.x86_64
ImageMagick-6.8.6.3-4.fc20.x86_64
php-pecl-imagick-3.1.0-0.7.RC2.fc20.x86_64