Results 1 to 8 of 8

Thread: How to Include EXIF File Date and Time?

  1. #1
    Join Date
    Dec 1969
    Location
    .
    Posts
    8

    Default How to Include EXIF File Date and Time?

    I am using the 64bit version of Thumbnailer 10.1.0.4 on Windows 7, Service Pack 1.

    I would like to output source HTML pages that include the I've clicked the "More Options" button from the main Thumbnailer screen, then go to HTML Output > Source Pages >Source Pages Text

    From there I go to the bottom box labeled "...source image tags go here" I have some standard text entered in that area, but also would like to include EXIF data, such as the date and time from the "DateTimeOriginal" field. I'd like the data to appear such as 1/8/2011 - 1:52:12 PM.

    I've tried adding the variable this way: &Exif.Image.DateTime but had no luck.

    Can someone point me in the right direction? Thanks in advance for any ideas on this.

  2. #2
    Join Date
    Mar 2006
    Posts
    928

    Post Re: How to Include EXIF File Date and Time?

    To get the EXIF DateTime tag, use the Exif operator. The ID of the DateTime field is "306" (these IDs are listed int he ThumbNailer help file). So, the TN expression to get the date/time out of the source file, on the source page is:

    Code:
    &Exif(srcFile, 306)
    And that will print something like "2000:12:11 18:49:48"

    The EXIF DateTime is stored in this format: YYYY:MM:DD HH:MM:SS

    Getting that into the format you want will take a little work. This should do it:

    Code:
    &VarSet("EXIFDT", Exif(srcFile, 306))
    &VarSet("EXIFYear", Left(EXIFDT, 4))
    &VarSet("EXIFMonth", Mid(EXIFDT, 2, 5))
    &VarSet("EXIFDay", Mid(EXIFDT, 2, 8))
    &VarSet("EXIFHour", Mid(EXIFDT, 2, 11))
    &VarSet("EXIFHourConv", If(Grtr(EXIFHour,12), Sub(EXIFHour, 12), EXIFHour))
    &T(EXIFMonth)/&T(EXIFDay)/&T(EXIFYear) - &T(EXIFHourConv):&Mid(EXIFDT, 5, 14) &If(Grtr(EXIFHour,12), "PM", "AM")
    You can just copy that to your source page template, anywhere you want to output the EXIF time.

    In case you want to know, here's how that works...
    First line copies the EXIF date/time to a temporary variable.
    Second line extracts the year digits from that temporary variable.
    Third line extracts the Month. Fourth line extracts the Day. Fifth line extracts the hour.
    Sixth line looks at the hour and subtracts 12, if the hour is greater than 12. Stores that in another temporary variable.

    The last line outputs the year parts, in the standard US order. Then it outputs the converted hour, then the minutes and seconds, then looks at the original hour to choose between AM or PM.
    Last edited by Admin; 01-08-2012 at 03:19 PM.

  3. #3
    Join Date
    Dec 1969
    Location
    .
    Posts
    8

    Default Re: How to Include EXIF File Date and Time?

    Thanks for the fast reply and the explanation of how you pulled this data. I appreciate the detailed answer, because it will come in handy if I want to modify the data shown or the formatting used.

    Thanks again!

  4. #4
    Join Date
    Dec 1969
    Location
    .
    Posts
    8

    Default Re: How to Include EXIF File Date and Time?

    One other question that may help me help myself with EXIF data

    How did you determine that EXIFDT, 2, 11 would return the hours in the EXIF data? And if EXIFDT, 2, 11 returns hours, and EXIFDT, 5, 14 returns seconds (from what I surmise from your code), where did the minutes value come from?

    Sorry to return with more questions. I did an internet search for EXIFDT values, but did not find any reference that spoke to values such as "EXIFDT, 2, 11"

  5. #5
    Join Date
    Mar 2006
    Posts
    928

    Default Re: How to Include EXIF File Date and Time?

    [I][SIZE=2][FONT=arial]
    How did you determine that EXIFDT, 2, 11 would return the hours in the EXIF data?
    OK... so, thanks to this line ...
    &VarSet("EXIFDT", Exif(srcFile, 306))

    ...EXIFDT will contain the entire contents of the EXIF DateTime field. Which, with my test image, was "2000:12:11 18:49:48".

    Then, this line:
    &VarSet("EXIFHour", Mid(EXIFDT, 2, 11))

    ...copies two characters, from EXIFDT, starting at position #11, into EXIFHour.

    2000:12:11 18:49:48

    ...and that is the "18".

    [I][SIZE=2][FONT=arial]
    and EXIFDT, 5, 14 returns seconds
    &Mid(EXIFDT, 5, 14) outputs 5 characters, starting at position 14. And those are "49:48".

  6. #6
    Join Date
    Dec 1969
    Location
    .
    Posts
    8

    Default Re: How to Include EXIF File Date and Time?

    I have a series of photos taken at 12 p.m., for example, in the EXIF data, the "Original Picture Taken" and the "Digitized" value for one of the images is 12:24:56 P.M. From the explanation of how this works, the script looks to the original EXIF time and determines whether it should be AM or PM. I've found that the script is identifying the photo as AM instead of PM.

    Here is an example image where I am experienceing this issue http://icestormcity.com/sfl/misc/DSC_1933.jpg

    Thanks for any help on this.

  7. #7
    Join Date
    Mar 2006
    Posts
    928

    Default Re: How to Include EXIF File Date and Time?

    changing the last line of that script from:
    Code:
    &T(EXIFMonth)/&T(EXIFDay)/&T(EXIFYear) - &T(EXIFHourConv):&Mid(EXIFDT, 5, 14) &If(Grtr(EXIFHour,12), "PM", "AM")
    to this:
    Code:
    &T(EXIFMonth)/&T(EXIFDay)/&T(EXIFYear) -  &T(EXIFHourConv):&Mid(EXIFDT, 5, 14) &If(Grtr(EXIFHour,11),  "PM", "AM")
    should do it.

  8. #8
    Join Date
    Dec 1969
    Location
    .
    Posts
    8

    Default Re: How to Include EXIF File Date and Time?

    Thanks for your help - I got it to work now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •