Hello,
I wonder whether it is possible for zenphoto to attach meta tags to cached images.
Here's my problem:
All my images have copyright information embedded. This shows up correctly in the zp backend - when I check an image "Credit" and "Copyright" both have information.
On my gallery I don't use full-size images but resized versions generated by zenphoto. When I save one of those cached images to my desktop and open it in Photoshop all the data fields are empty.
I dug through the source a bit and from all I could tell zenphoto does indeed not add meta data to images it creates?
Is this correct or is there something wrong with my setup? Is there any way to write the meta data into the cached images? Would using imagick instead of GD make a difference?
Thanks,
Philip
Comments
even though that's what I was afraid of - it will cost me some money if I want my host to install imagick for me (and I actually failed at installing it myself even locally).
One more question however, you write that GD doesn't support meta data. But it appears PHP supports embedding them - see the manual for iptcembed. Also this stackoverflow question suggests it is possible.
I thought about doing it via a plugin, but from what I can tell it would be necessary to have a filter that gets called when an image is cached and I didn't find such a filter?
Thanks,
Philip
There is no filter for when an image gets cached. Mostly because Zenphoto is pared down to "bare bones" for this to make the maximum memory possible available for the image processing.
If I were to write my own plugin...
My images are always the same size, so I guess that I could call a function on the filter "new_image" so that each new image is automatically cached in the right size and in that cached version the meta data would be embedded.
Does that seem like a good way to go?
Else I can't think of a way where I would not have to check every image for meta data before displaying it. But maybe I'm just confused now.
Anyway, thanks for your help and thanks for zenphoto, I really dig it a lot.
Probably the option is for Lib-GD only since I believe that Lib-Imagick already does this. But our lib-imagick developer will have to comment further on this.
I'm also interested in whether it already works with imagick though.
i gave a try to the dev version of zp to see if the iptc metadata were correctly copied into the cached image file. well for me it didn't work. i am using the GD library.
if no iptc data are to be found, the default values (copyright and credit) are not written in the file. i tried to see where the problem is coming from. and it seems to me the image object is not defined so any call like `$image->getCredit()` is not working. in fact i think the album object `new Album(new Gallery(), $albumname)` is not defined because $albumname is wrong. if i print $albumname i get something like /Users/frank/.../.../.../albumname instead of just albumname. now if i replace `$albumname=dirname($imagename)` by `$albumname = substr(dirname($imgfile),strrpos(dirname($imgfile),'/')+1)` then things work better.
that is what i found. maybe i am doing something not correct. does anyone else has tried to see if the iptc data were properly wrote in the cached files ?
(i wanted to post this on the trac ticket but for some reason my login and password do not work anymore. is it a problem to register again with the same email address and same login ?)
Anyway, not sure what you are saying about the image not being defined. Do you get errors? Certainly the code leading into this:
`
$imgfile = str_replace(ALBUM_FOLDER_SERVERPATH, '', $imgfile);
$imagename = basename($imgfile);
$albumname = dirname($imgfile);
$image = newImage(new Album(new Gallery(),$albumname), $imagename);
`
Will create the image object from the proper names.
now back to caching image with iptc data. i do not get errors. the cached file is created just like before but no iptc data are in it.
so i printed few things in a file to see what was going on (i am working on my local server for dev purpose).
$imgfile gives /Users/frank/.../.../albumname/imagename.jpg
$imagename gives imagename.jpg
$albumname gives /Users/frank/.../.../albumname
if i print $image->getTitle(), i get nothing but i checked in the database and i do have something in the title field.
to go a bit further i replaced `$image = newImage(new Album(new Gallery(),$albumname), $imagename);` by:
`
$albumobj = new Album(new Gallery(), $albumname);
$image = newImage($albumobj, $imagename);
`
this way i have access to the album object. if i try to get the album title with $albumobj->getTitle(), i get nothing again. i am able to get the album title (and description with getDesc) only if i replace `$albumname = dirname($imgfile);` by `$albumname = substr(dirname($imgfile),strrpos(dirname($imgfile),'/')+1);` to get rid of /Users/frank/.../.../ in the album name.
and then i get something when i print $image->getTtile() or anything else (getCredit, getDesc, getCountry...)
i hope this makes it a bit clearer.
i checked that ALBUM_FOLDER_SERVERPATH was defined and it was not. the thing is having the trunk and dev versions on my computers, it get sometimes messed up. i have reinstalled the dev version and guess what it works. i am really sorry. i need to be more organized on my side to avoid this kind of thing in the future.
`$iptc = array('1#190' => chr(0x1b) . chr(0x25) . chr(0x47),...` must be replaced by `$iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47),...`