exif data

IMagick is a native PHP extension to create and modify images using the ImageMagick API. ImageMagick Studio LLC did not write nor does it maintain the IMagick extension, however, IMagick users are welcome to discuss the extension here.
Post Reply
AliceWonder
Posts: 11
Joined: 2014-07-09T21:41:34-07:00
Authentication code: 6789

exif data

Post by AliceWonder »

Hi, trying to prevent things like geo-location etc. from being included in exif data while not completely getting rid of all exif data that may be present.
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, '');
		}
	}
}
It appears to work in that after running that function on an image object, looking at the properties only shows exif data that is suppose to be preserved.
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
AliceWonder
Posts: 11
Joined: 2014-07-09T21:41:34-07:00
Authentication code: 6789

Re: exif data

Post by AliceWonder »

Okay - http://pecl.php.net/package/imagick seems to indicate what Fedora has packages is somewhat out of date.
I'll try building a newer version and see if I can nag Fedora to update what is in their repositories.

Don't know if it will fix this, but...
Post Reply