Meta data for cached images?

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

  • acrylian Administrator, Developer
    Zenphoto itself is not able to attach meta data, but if you use Imagick instead of GDlib that should preserve the meta data from the full images uploaded. (GD does not support meta data at all).
  • Thanks acrylian,

    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
  • what GD does not do is preserve metadata when it works with images, so resized images loose the metadata. Using the above I suppose a plugin could imbed the metadata after the images are resized.

    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.
  • acrylian Administrator, Developer
    Did indeed miss that there is actually a function for embeeding.
  • Do you think this is worth submitting a ticket for?

    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.
  • I think the best way to go is to make a ticket to have Zenphoto replicate the IPTC data from the source image to the copy. That could be done as an option (doing so with the above function requires essentially a file copy of the resized image, so not everyone will want it.)

    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.
  • Okay, I've submitted a ticket.

    I'm also interested in whether it already works with imagick though.
  • lib-Imagick does already have this functionality in `zp_resampleImage()` since 1.3.1, I believe.
  • hi,

    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 ?)
  • From time to time we clean up the Track user list. Eliminate anyone without an e-mail address to try to cut down on SPAM. Perhaps you did not include your e-mail.

    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.
  • i will register again to use the track. i'll make sure i'll give an email address.

    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.
  • ooops,

    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.
  • No problem. We really do appreciate the testing. Sorry about deleting you Track ID. BTW, the e-mail address helps you with the TRACK as well. You get copies of postings to the ticket then. (One of the reasons we suspect user IDs with no email. who does not want to know about responses to his ticket?)
  • one thing concerning the UTF-8 settings. it is the field 1:90 that must be set so
    `$iptc = array('1#190' => chr(0x1b) . chr(0x25) . chr(0x47),...` must be replaced by `$iptc = array('1#090' => chr(0x1b) . chr(0x25) . chr(0x47),...`
  • You will have to help me out here. My eyes must be failing, but I see no differnce between what you say the replacement is and what you say must be replaced.
  • the difference is in the first key of the array. we have `1#190` and it should be `1#090`. hope this helps.
  • Thanks. Just could not see it. You are right, it should be 090.
Sign In or Register to comment.