Page 1 of 1

setImageProperty Not Working After stripImage

Posted: 2013-11-04T08:53:33-07:00
by patrickr
Hi

I'm using PHP Imagick 3.0.1 with ImageMagick 6.7.6-8. When I try to add metadata to a png using the following code, my property is missing when I re-open it and call getImageProperties().

# read an image into $image...
$image->setImageProperty('test:x', '123');
$image->setImageFormat('png24');
$image->writeImage($saved_img_path);

Any idea what the problem could be?

UPDATE:

I realized what the problem was. I was calling stripImage before adding a property, on the assumption that stripImage wouldn't strip properties added after it was called.

Is there a way to read, strip, add a property, and save an image? Given how stripImage seems to work, I'd have to read and write the image twice. Once to strip and once to add my property.