Using EXIF data not stored by Zenphoto

I have tried to find a way to add a tag that is not stored when the image is discovered and doesn't have a tick for in the options but I can't seem to. Is there a way (without changing core files) to do this? The tag info (Software 0131) gets parsed but not saved in the DB.

Currently I am calling read_exif_data_protected($_zp_current_image->localpath) on my image page and then pulling out the Software tag if the Make tag is Hipstamatic greater than Model 252. The Software tag contains info on the processing that was done when the photo was taken. Then I just strip the three items out and format them for display.

It just seems like I am taking the long way around. If anyone could point me in the right direction that would be great.

Thanks.

Comments

  • acrylian Administrator, Developer
    So you have exif data that is not read? What release? If not 1.4.3 please upgrade.
  • Yeah tag "0131" but there doesn't seem to be a matching item in the image options to select it either. It is in the exif.php but the "Software" tag does not make it into the DB.

    I'm using version 1.4.2.2 [9365]. With a very modified version of zpMinimal. Yeah, I was getting ready to upgrade soon, I guess I will have to give it a go on my test server. I just wanted to be sure I wasn't missing something easier (on the theme side) to avoid re-parsing something that was already parsed.
  • If the EXIF item does not show up in the offered list then it is not being processed by Zenphoto. Only way to change that is to modify the core.

    This is a two-fold issue. First the exifier code has to process the tag. That seems the case for 0131--it is an IFDO tag. Second the `exifvars` array in functions.php needs to have an entry for the tag. This is probably all that is missing for the `software` tag.

    probably adding the following line would do the trick:

    `'EXIFSoftware' => array('IFD0', 'Software',gettext('SOftware'), true, 999, true),`

    Let us know if it works, we can add it to the next release.
  • Thanks sbillard, that is exactly what I thought. I'll have to update to the latest version before doing that to make it valid. I had been holding off since my live host is at PHP 5.3.10 and it seems there were some issues.

    Reading through the comments (in functions.php) it did seem adding that tag in functions.php and running setup would do the trick. I just didn't want to change anything at the core level especially something that would change the DB. I guess right after the EXIFFocalLengthIn35mmFilm might be a good place for it.

    The direction is much appreciated. I will let you know how it goes and open a ticket after so it is not forgotten.
  • Great. BTW, PHP 5.3.10 may or may not be an issue. I have it on my local installation. Sometimes setup will not run and sometimes it will.

    At the moment I am successfully running 5.3.10. When it does fail, simply adding lines of code to try to figure out why it fails makes it work again. I kind of think it must have to do with file sizes or some such strange thing.
  • Okay, I updated to the latest trunk, Zenphoto version 1.4.3.1 [10590] without much trouble. Just a few odds and ends I had to fix that changed (like the right and left quotes for the navigation) before trying to add the new EXIF tag in.

    Added to functions.php at line 2322,
    `

    'EXIFSoftware' => array('IFD0', 'Software', gettext('Software'), true, 999, true),

    `
    (tabs and whitespace removed to protect sanity...)

    Then I ran setup and refreshed the metadata for a small album. Everything worked well. The new tag shows up in the image options and works as it should.
    Since I did want to process the info from the tag further I selected it as "hidden" then got at the info using,
    `

    $exif_tags = getImageMetaData($_zp_current_image,false);

    `
    so I could get at the three tags I was interested in for the DB instead of the image. Then I processed the EXIFSoftware tag to get at the three items stored in it and display them individually. The only thing that would be nice if there were a function in template-functions.php that would allow to retrieve only a specific tag (or array of tags). Something like getImageMetaItem($image,$tagname). I suppose I could just hand roll a new printImageMetadata() that did what I wanted and put it in my theme functions.php file as well.

    I think I have to create a new account to open a ticket for this. The last time I tried it seemed my old one perhaps got purged.

    Anyway, thanks for the ideas. I now have a nice little display of what processing (lens, film and flash) that my Hipstamatic images were shot at. The final result can be seen here. http://www.sowearedads.com/snaps5/IMG_8940.JPG.php

    Enjoy the weekend...
  • Ah, one last thing. My live server is running PHP 5.3.10 and everything went well. :)
  • All objects have a base method named `get()` to which you pass the database column name. So you can retrieve the software tag with `$tag = $image->get('EXIFSoftware');`

    You do not need the `getImageMetadata()` call in general as the metadata will be automatically loaded. But since this is a new field you would need to use the admin refresh metadata button to get it loaded in the first place.

    You can skip the ticket. I will add the code for the 1.4.4 release. Thanks for the testing. Probably I will default it to hidden since that seems what you wanted in the first place.
  • Okay great. I think that is how I inserted it as well. I had to change it show while testing. Thanks.
  • Ah, of course I can get it using the image methods. I don't know why I was hung up on using the template-functions.php functions. Overthinking it I guess...
Sign In or Register to comment.