Exif

After some interesting discussion inside the topic "Which IDE and Debugger to run zenphoto?" I created this topic because it will focused on Exif.

@Trisweb
* Do you have some design/architecture advices?
* Additional Fields inside MySQL/image Table...do you mean Tags? (Metadata like
Familie, Holiday, Work etc.?)

@Thinkdreams
* Exifer 1.5 is able to handle Nikon and Casio Images.
* When we put Exif Information inside the MySQL/image Table wouldn't we create
redundant information. For sorting the date info it make sense...

@all
* every help is welcome

Comments

  • trisweb Administrator
    Design architecture advice, sure...

    This is basically going to be a function that class-image.php uses to get EXIF information. So we need a couple things...
    1) A function that takes an image as input and outputs some kind of set of EXIF data for it (an array, object, whatever).
    2) Methods for getting that data into predefined database fields for the image. (Me)
    3) Methods for checking the filemtime of the image, and if it has been updated, refresh the image EXIF data back into the cache. (Me again)
    4) Then, if all looks up-to-date, use the database info instead of re-processing the EXIF.

    Re: Additional fields/redundant information: These are NOT tags, I'm talking about duplicating (caching) the EXIF data in the database. Parsing a file for its EXIF data is an intensive process. We can do benchmarks to find out just how intensive it is, but I know it's not simple. Reading data from a database, on the other hand, is very fast, plus we already do a query for each image so adding an additional 10, 20 or even 30 fields won't slow anything down beyond the already existing query overhead. The EXIF will only need to be read from the image once per image update, which is good.

    If you mean that some data will always be the same, like camera model, then I agree completely, we could use an ID instead into an exif data table. But for most of the exif data, it varies a lot, so it won't be very necessary. We'll look at the data and decide later if we need to alter the schema.

    So let's get that EXIF library reading image data first, make a new method in the Image class to read it, process it, and store it by using $this->set('variablename')*, and don't worry about the database caching just yet. I'll take care of that.

    * $this->set('variablename') with a variablename that's not in the database was just implemented, it's in SVN but not in 1.0.8. We'll get there...
  • stef Member
    @thinkdream
    * Performance is a good issue...you are right.
    * How to store Exif inside MySQL, as one (Multiline-) String or dedicade 5-30 fields? I
    ask, because it seems to me that different brand (Nikon, Casio, Sony) has sometimes
    different Exif Tags. Hm, dedicaded fields could be easier to handle.
    * Lets start with "exif-functions.php"?

    More in the evening...
  • @stef-

    Tris in a previous post suggested storing one EXIF field per column, so I think dedicated fields would probably be the best thing.
  • stef Member
    @thinkdreams
    * I will try to use Exifer 1.5 to get the five important fields (date, time, Camera)
    and put them into the images table fields like date, time etc..
    This functionality will be inside a new exif-functions.php.
    * For more integration I would need a deeper understanding of Zenphoto Architecture (yes I
    know the old joke "the source code is the docu").
    * In the long run, it would be nice to use the Exif date information to show the photo
    distribution over the last years in a timeline. But this is a differnt story
  • trisweb Administrator
    @stef -- don't worry about storing it in the database yet, just get them and return them manually for each image. The database will just be a cache, and I'll handle that.
  • Gotta figure out what it all means, but here's a start:

    http://www.thinkdreams.com/devzen/index.php?album=vermont&image=hi_bunnies.jpg

    (Aren't the bunnies cute?)

    Oh, sorry. Try looking at the raw EXIF data below. :)

    Another example is:

    http://www.thinkdreams.com/devzen/index.php?album=njsummer&image=IMG_2129.JPG

    which has better camera info.

    Looks like everything is already in an array.

    Implemented by:

    In the image.php
    `

    <?php include ('zen/exif.php'); ?>

    <?php<br />
    $path = "../" . getFullImageURL();

    $verbose = 0;

    $result = read_exif_data_raw($path,$verbose);

    echo "
    "; 

    print_r($result);

    echo "
    ";

    ?>

    `

    And in the zen directory I placed the makers dir and the exif.php from the Exifixer library.

    The code above is basically taken from the index.php file supplied with the distribution.

    Really rough, but a start.
  • The cool thing is that the maker information is abstracted (or separated) from the core exif library, so technically you could write camera support "makers" for new cameras with errant tags thereby effectively supporting many different types of cameras.
  • trisweb Administrator
    That's good! Yeah, I remember seeing makers as different subsections in Exifixer, so that was a plus. Looks like it's working well. I like the way it translates the numerics into readable values (Eg: 1/60 sec, and f/2.8)
  • From here, we need to decide what to get by default. I'm guessing like Stef said the biggies:

    date and time,
    camera make and model (looks like two fields)
    fstops,
    exposure time,
    aperture?,
    flash (yes or no),
    focal length,
    orientation (important for rotation)

    Looks like the raw data returned pretty much takes care of these, and these should be common among most, if not all maker data with a few exceptions.

    I'm not fantastic on arrays and data processing. To be really honest, I stink. How are you at arrays Stef? Since there potentially is a large amount of data, we need to find the commonly used data, and maybe just grab those rather than the whole raw set of data?

    Am I even making sense? It's been a looooong week.
  • trisweb Administrator
    Yep, making some sense there :)

    I guess you'd just want to find where the data resides in the array, and just reference it and assign it to some variables... something like...

    `$result = read_exif_data_raw($path,$verbose);

    if ($result['ValidEXIFData'] == 1) {

    $aperture = $result['SubIFD']['ApertureValue'];

    $exptime = $result['SubIFD']['ExposureTime'];

    ...

    }`

    Then you have your EXIF data :-)
  • stef Member
    @thinkdreams, trisweb
    * Shit happens...my Linux hard disk has a defect MBR. This is the second time that a
    Maxtor HD become damaged in 4 weeks.
    * I will be back as soon as possible.

    @thinkdreams
    * My first thoughts with "bunnies" are...of course rapids.

    Question:
    * After a new installation did it make sense to use LAMPP in place of seperate Apache2,
    PHP 5 and MySQL?
  • trisweb Administrator
    Stef, LAMPP on a Linux sys? I'm not sure if it comes prepackaged or what...

    If you're using Debian/Ubuntu, just use apt-get, it integrates everything correctly and works great. On gentoo obviously use emerge. Not sure what distro you're using.

    No worries about delays :)
  • @stef-

    I know that this statement will sound pretty opinionated (I apologize), but
    speaking from experience (as a network admin with lots of years of tech support experience), never, never, never buy maxtor again. they have the worst industry record for failures and errors. stick with seagate or western digital, generally speaking they have decent track records. all hard drives fail, but maxtor seems to suck more than all the others.
    We had a mission critical NAS appliance at work by maxtor and it was awful. it crashed all the time, and for a business file server system, that isn't good. we ended up going back to an HP Proliant rack server after 1.5 years using it, and we replaced the unit's drives at least 3 times during that time.

    (Maxtor no longer makes NAS appliances BTW)

    And what the heck do rapids have to do with cute little bunnies? ;)
  • trisweb Administrator
    Craig, that's good info. I've got a Maxtor 250GB drive in my comp and it's worked great for over a year now, so I guess some aren't as bad as others, but I've always like WD/Seagate as well (Bought a laptop drive from Seagate that's blazing and super stable, quite nice).

    I am also curious as to what the heck rapids have to do with bunnies. :-)
  • I´m looked for the Exif-function too (I found a ToDo at the ZP exif function - and i wanted to code a new function).
    I recognized, that the PHP-Function exif_read_data() [http://de2.php.net/manual/de/function.exif-read-data.php] not always do, what they have 2 do (PHP Package must be Compiled with --enable-exif to work). And now i have found your thread that you still work on the exif function for ZP. Nice =) ^^

    *Thread Merged*

    sry 4 my shitty ^^ english

    Tom
  • stef Member
    @all
    I'm back...or should I say my LINIX PC is back.
    VMWare:
    * After this bad experience I thinking about using a VMWare Image with all necessary
    things inside (Zenphoto source, LINUX, Eclipse PHP IDE, Apache2, MySQL etc.). It will
    be only for testing and codeing.

    Exif:
    * I will create a Exif function (ExifValue(TagName)?) that is able to read ExifTags and
    returns the value of the ExifTag.
    * Does it make sense for you?
  • We already, within the Exifixer library, have a function that returns the raw tags. So a function to return the tags is already there for us to use (see my examples). What we need now is a way to take those tags that the raw function returns, and assigns them to variables, based on what tags we decide to start using. We probably don't want to assign every tag possible to variables, just the common ones. Then Tristan I believe will take those variables, and cache the stored data in the DB, right Tristan?

    So, we can either rewrite the raw tag function, or write a new one that does the same thing (I'm thinking a new function that stores into variables rather than displays would probably be best)
  • trisweb Administrator
    Sounds like a plan. Craig, have you done anything other than adding the Exif library? If you have could you please send me it in email? Thanks.
  • Nope. I haven't. I'm still bringing my company back up to 100% from a large virus outbreak (Spybot/Rinbot worm) which hit our slightly out of date Symantec scanning engine. The funny thing was, our virus defs were good, it targeted a security hole in the slightly older version we were running. So word of advice, make sure you run the latest virus defs AND the latest engine if you run windows boxes. The virus writers are hitting Symantec products pretty hard right now.

    All I really need to do is write the function that grabs the tags from the image and drops them into variables as you outlined above. Then I can hand it off to you to look over. Hopefully within the next week or so, earlier if I can free up some time.
  • OK. Got some more fleshed out:

    http://www.thinkdreams.com/devzen/index.php?album=njsummer&image=IMG_2120.JPG

    If you note, it displays the image information before the print_r statement (which prints out all the raw data). Thus I have most of the common EXIF information now stored as variables, which you should be able to take a then cache in the DB using the functions you're writing. Once we have the data in the DB, then we can do fancier stuff like automatic image rotates if it's out of rotation, etc.

    I've sent this to you via email Tristan. See what you can make of it, and let me know how you want me to proceed further. I think I've covered most of the major variables. A lot of the maker data for specific camera models is pretty much redundant or unnecessary IMHO.
  • stef Member
    @thinkdreams
    Looks great...how to get it? I'm still engage with Exif theme, but I struggle now a little
    bit with the programming structure. BTW, how could a good zenphoto documentation look
    like? UML ?
  • Tristan's looking at the code right now, but here's what changes I've made so far:

    Modified Exifixer libs and added function to assign exif tags to variables.
    Modified image.php to add display of raw EXIF data and variable data.

    If you send your email address to me at craig@thinkdreams.com I'll be happy to send the changed files to you. I'm using the effervescence theme for testing, but you should be able to drop the code into any theme.
  • And as far as docs Stef, Tristan's started fleshing out the documentation on the wiki, and I think that's where the docs will live. I would imagine we'd eventually see a PDF version or whatever, but the wiki format is fine by me because it's always available.

    The docs are very much in the beginning stages, so don't expect a large amount of user information until more contributions are made to it. Feel free to contribute though!
  • stef Member
    @thinkdream
    Please send me the Exif Code...if there is a problem with my email I will send it again.
    Thanks in advance
    @trisweb,thinkdream
    Docu: How to create Pictures/Grafik for the Zenphoto Wiki? Is there a prefered open source
    tool?
  • trisweb Administrator
    The Gimp is always good, or Inkscape if you want to do vector drawings.

    Looking through the EXIF code sometime this week... never enough time...
  • Sorry Stef- Hang on. Got your email. Tris is right. Never enough time. Especially when they change daylight savings time on us.....
  • stef Member
    @thinkdreams
    Thanks for your code. It works. I thinking about how to put this information inside MySQL or should we
    wait for Tristan?
    What about your theme "thinkdream"? Does it make sense to upgrade them to exifer?
    @trisweb, thinkdreams
    Is there a way with svn to merge the different code variants together? Do we have different code
    branches?
  • trisweb Administrator
    I can make a new branch for you, but I would prefer you simply submitted patches to me for now. I actually have all of Craig's code, if you want me to make a branch with it. Sorry I haven't kept up, I'm quite busy right now...
  • I think we should continue to submit as patches rather than creating a new branch for it. Might get confusing after a while, considering you're also looking at RSS (hopefully) soon too for 1.1.

    And take your time. Have to pay the bills somehow. I might be in and out the next two weeks anyway, as it's Linux training time for my company...

    :)
  • stef Member
    @thinkdreams
    I changed your theme "thinkdream" to use Exifer libs. Coming from J2EE I'm still surprised
    how easy it is to integrate new functionality in PHP (but still missing a PHP debugger,
    sigh)
    @trisweb
    This weekend I will try to write the Exif information to MySQL. Tris to you have some recommendation for me where to put the code? It is just another PHP programming test
    step for me...
Sign In or Register to comment.