StopK2... Any PHP gurus out there?

I'm trying to add EXIF data to the StopK2 theme. Haven't really tweaked StopK2, other than eliminating the php short codes which my host doesn't seem to like. Anyway, since my host doesn't have the exif.php support enabled, I downloaded exifer1_9.zip and unpacked it in the /zenphoto/zen directory, then added an include 'exif.php' in template-functions.php. Then, I added a bit of code in image.php right under the comment div that calls a function in exif.php to read the data. Right now, it just dumps the results without any prettifying, but making it legible is easy.

Now for the problem. It works for all the images *except* the first image of the first gallery. It doesn't matter if I select that image first, or whether I select others first. At first I thought the exif data for the jpg was bad, but I verified the exif data was good in the second file, deleted the first one, and now the second image didn't work anymore.

It seems like when it calls the function in exif.php, the whole exif.php file is getting dumped. You can see it here:

www.desilva.info/zenphoto

The exif data only shows when you select an image, so you have to go into a gallery and then pick a photo. Try the first photo, then try any other photo.

Any ideas?

Comments

  • Figured it out... Use of short codes in the /maker includes. *sigh*
  • trisweb Administrator
    Cool, looks like a very nice clean theme that goes well with K2. Releasing it publicly anytime soon?
  • trisweb Administrator
    Ah, right... definitely need the Wiki back up....
  • Steve-it is a nice theme... The site is really not yet for public consumption, but I will include a credit, and, in that regard, do you have a preferred link-back?

    BTW, I also hacked in some code for the image.php page to show EXIF data. Not very clean (I am a total PHP newbie), but if you want it... Tristan, just out of curiousity, I did an "include 'exif.php'" in template-functions.php--should that be a "require" or "require_once" (its really just functions used in the theme's image.php)? Is that the best place for it?

    I was going through fits trying to figure out why I could view certain EXIF tags (mainly the makernote tags) in Adobe Bridge CS2, but I couldn't extract them with the exif.php module. Made some ugly discoveries:

    -- First, if you use "save for web" in Photoshop, it totally kills *all* EXIF data to save space.

    -- Second, even if you use "save as" and preserve the EXIF, it does *not* preserve the "makernote" tags that have some useful stuff (like lens data). I could see the stuff in Bridge CS2, but the EXIF tags just didn't show up. It was driving me nuts until this morning when I learned that Adobe's programs write all that stuff into something called XMP (eXtensible Markup Protocol).

    Anyone know of a PHP module that will read XMP? Aie.
  • Apparently there is a PHP tool to extract XMP data from jpgs available:

    http://wiki.creativecommons.org/XMP

    But since it has to be compiled into PHP, doesn't do those of us w/o control over the server any good. If anyone knows of a standalone tool...
  • jO3L Member
    Hello

    new to zenphoto and wordpress, I succeded, due to the forum, to integrate ZP and WP using the same solution as ed2.
    I saw you managed to produce nice exif informations. I tried to do it also on my website but I get all the exif information, unformatted. On some files my code won't find the photo file at all.
    see for exemple http://joel.schatzman.eu/gallerie/
    I guess I could manage to get it correct if you could show me the php files you had to modify.
    with many thanks
  • ed2 Member
    The changes to zenPHOTO/StopK2 included altering image.php in the theme to call exif.php functions and print data. To do this, I unpacked the exifer zip in the /zen directory, added an include to zenPHOTO’s template-functions.php, reset the links in exif.php to add /zen to get to the includes, and changed the PHP short codes in the beginning of the exif.php and /maker files.

    The lines I inserted in image.php--borrowing code from others on the forum--to show the data are below. The new code went right after the div commentblock...

    `<?php
    $exif_image=substr(getFullImageURL(), 10);
    $exif_result = read_exif_data_raw($exif_image,0);
    $longdate = $exif_result[SubIFD][DateTimeOriginal];
    if($longdate !=NULL) {
    list($fulldate, $fulltime) = explode(' ', $longdate, 2);
    list($year, $monthnum, $day) = explode(':', $fulldate, 3);
    list($hour, $minute, $second) = explode(':', $fulltime, 3);
    $num[0] = "/01/";
    $num[1] = "/02/";
    $num[2] = "/03/";
    $num[3] = "/04/";
    $num[4] = "/05/";
    $num[5] = "/06/";
    $num[6] = "/07/";
    $num[7] = "/08/";
    $num[8] = "/09/";
    $num[9] = "/10/";
    $num[10] = "/11/";
    $num[11] = "/12/";
    $alpha[0] = "January";
    $alpha[1] = "February";
    $alpha[2] = "March";
    $alpha[3] = "April";
    $alpha[4] = "May";
    $alpha[5] = "June";
    $alpha[6] = "July";
    $alpha[7] = "August";
    $alpha[8] = "September";
    $alpha[9] = "October";
    $alpha[10] = "November";
    $alpha[11] = "December";
    $month = preg_replace($num, $alpha, $monthnum);
    if ($hour >=13) $cleanhour = $hour -12; else $cleanhour = $hour;
    }
    if ($exif_result[IFD0][Artist] != NULL) {
    echo "Shot by ".rtrim($exif_result[IFD0][Artist]);
    if ($longdate !=NULL) {
    echo " on $month $day, $year at $cleanhour:$minute ";
    if ($hour >=13) echo "PM"; else echo "AM";
    }
    echo "";
    }

    if ($exif_result[IFD0][Model] != NULL) {
    echo "Set Up: ".rtrim($exif_result[IFD0][Model]);
    if ($exif_result[SubIFD][FocalLength]!=NULL) echo " (".$exif_result[SubIFD][FocalLength].")";
    if ($exif_result[SubIFD][ExposureProgram] !=NULL) echo " on ".$exif_result[SubIFD][ExposureProgram];
    echo "";
    }

    if ($exif_result[SubIFD][FNumber] !=NULL) {
    echo "Exposure: ";
    list($expL, $junk)=explode(" ", $exif_result[SubIFD][ExposureTime], 2);
    list($expN, $expD)=explode("/", $expL, 2);
    $d=intval($expD);
    $n=intval($expN);
    if(($n/$d)>=1) $exposure=strval($n/$d)." seconds"; else {
    if($n==1) $exposure=$expN."/".$expD; else $exposure="1/".$d/$n."th of a second";
    }
    echo $exposure." at ".$exif_result[SubIFD][FNumber];
    if ($exif_result[SubIFD][ISOSpeedRatings] !=NULL) echo " (ISO ".$exif_result[SubIFD][ISOSpeedRatings].")";
    echo "";
    }
    echo "".rtrim($exif_result[IFD0][Copyright])."";
    ?>'
Sign In or Register to comment.