Imagick and IPTC headers
Closed this issue · 5 comments
I know it is not possible to preserve IPTC headers while using the GD adapter, bug Imagick supports this (I guess Gmagick does as well).
It would be nice if resize() could also resize images like THUMBNAIL_INSET does, but maintain IPTC information. And thumbnail() could get rid of the IPTC headers since you probably do not want to increase file size of your thumbnails.
I am not sure what IPTC headers
mean. Can you explain what you would like Imagine to do and give an example of how to do it? Imagine relies on PECL Imagick extension internally. I am not aware of how to manipulate IPTC headers from it.
IPTC headers are meta information attached to the image. Like what is the caption of the image, who took the photo, source of the image, copyright information, etc.
More information on IPTC headers can be found here -> http://en.wikipedia.org/wiki/IPTC_Information_Interchange_Model
To read IPTC headers I usually use PHP's builtin iptcparse() function and some custom logic, but there are other libraries for this, like this one -> http://www.ozhiker.com/electronics/pjmt/
I have dug around Imagines Imagick adapter and I see that for resizing an image and creating thumbnails you are using: Imagick::adaptiveResizeImage(), Imagick::cropThumbnailImage() and Imagick::thumbnailImage() methods.
After some testing a can conclude that the problem is that all this methods strip meta information from the image (maybe they also do other stuff). On one hand it makes sense because you do not want this information in the thumbnail. But, if you want to resize an image and keep this information this is currently not possible with Imagine.
When I resize images in my projects I use \Imagick::resizeImage($width, $height, \Imagick::FILTER_LANCZOS, 1, true) and the meta information is not lost.
I do not expect from Imagine to help me read or write IPTC information from and to the image, but loosing IPTC information is a show stopper for me. I guess a lot of people working with copyrighted material will have a problem with this.
I hope this explains a little more about the problems I am facing.
Regarding the resize method limitation I will open another issue when I get some time to elaborate a little more about it.
@gjuric I believe the metadata (including EXIF, IPTC and other formats) can be read and written using Imagick::getImageProperties()
and Imagick::setImageProperty()
, but I haven't tested yet. Will look into it.
Writing IPTC/exif metadata is not planned in the next future, closing this issue because of a lack of activity
If there is an interest for this, I'm currently writing an IPTC Reader (+ a Writer) relying on the MetadataReaderInterface
. I'd be happy to share (and clean up the code a little to send a PR)