Date Taken underneath thumbnail Date Taken underneath thumbnail
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

Date Taken underneath thumbnail

Started by altenae, November 21, 2011, 06:59:53 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

altenae

I have read al lot of topics about this modification.
None of them worked or they were for older versions..

What I want is the Date Taken also to be underneath the thumbnail just before the Date Added.
The date taken is coming from the exif informartion...

I have tried for some hours to make this possible....
I ask now here , because I haven tried but was not lucky.

Edward
www.planepix.nl

Αndré

I just tried to find a quick solution by adding
        if ($CONFIG['read_exif_data']) {
            include_once("include/exif_php.inc.php");

            $exif = exif_parse_file($CONFIG['fullpath'].$row['filepath'].$row['filename'], $row['pid']);
            print_r($exif);
        }

right after
foreach ($rowset as $key => $row) {
in include/functions.inc.php. (note: this isn't the final solution but displays the fetched EXIF data)

Unfortunately that function hasn't returned what I expected, at least in my testbed. If it also doesn't return the relevant data for you, we have to use something like
        if ($CONFIG['read_exif_data']) {
            include_once("include/exif_php.inc.php");

            $sql = "SELECT exifData FROM {$CONFIG['TABLE_EXIF']} WHERE pid = {$row['pid']}";
            $result = cpg_db_query($sql);
            if (mysql_num_rows($result) > 0) {

                $row = mysql_fetch_assoc($result);
                mysql_free_result($result);
                $exifRawData = unserialize($row['exifData']);
                print_r($exifRawData);
            }
        }

instead of the above suggested code.

altenae

The last suggestion it giving me an error:

While executing query 'SELECT title, keyword FROM cpg132_albums WHERE aid = ' in include/functions.inc.php on line 2784

mySQL error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1


In the old 1.3 (also a mod) I found this in the functions.inc.php

$caption .= '<br />'.$lang_display_thumbnails['date_taken'].localised_date($row['exifData']['DateTaken'], $album_date_fmt);

Date_taken was a new field in the table pictures....
Donnovan made this al long time ago.

No you have the date added underneath the field and with the requested mod you also have the date taken under the thumb.

altenae

I have it somehow working, but all exif info is displayed as output and not underneath the thumbnail.
I am interested in the field "Date Digitized" onl from the exif info.

Edward

altenae

So I need the info which you see when displayimage.php is used.

DateTime digitized: 2010:08:03 09:25:51 and then in the format Aug 03, 2010

Αndré

Quote from: altenae on November 22, 2011, 05:47:53 PM
I have it somehow working, but all exif info is displayed as output and not underneath the thumbnail.
That's what I meant with
Quote from: Αndré on November 22, 2011, 05:04:20 PM
this isn't the final solution but displays the fetched EXIF data


Quote from: altenae on November 22, 2011, 05:47:53 PM
I am interested in the field "Date Digitized" onl from the exif info.
Please post the output produced by the current modification (starting with Array).

altenae

I still get the SQL error when placed after "foreach ($rowset as $key => $row) {"

I have placed it now in the if statement "if (in_array('ctime', $must_have)) {"

The array displayed now for one thumnail (Placed above the block)

Array ( [VerboseOutput] => 0 [Errors] => 0 [ValidJpeg] => 1 [ValidIPTCData] => 0 [ValidJFIFData] => 1 [ValidEXIFData] => 1 [ValidAPP2Data] => 0 [ValidCOMData] => 0 [JFIF] => Array ( [Size] => 16 [Data] => JFIF�� [Identifier] => JFIF [ExtensionCode] => 02 ) [APP1Size] => 2692 [Endien] => Intel [IFD0NumTags] => 9 [IFD0] => Array ( [Make] => Canon [Model] => Canon EOS-1D Mark IV [Orientation] => 1: Normal (0 deg) [xResolution] => 240 [yResolution] => 240 [ResolutionUnit] => Inch [Software] => Adobe Photoshop CS4 Windows [DateTime] => 2011:11:18 16:02:16 [ExifOffset] => 216 ) [IFD1Offset] => 780 [SubIFDNumTags] => 31 [SubIFD] => Array ( [ExposureTime] => 1/1000 sec [FNumber] => f/5.6 [ExposureProgram] => Aperture Priority [ISOSpeedRatings] => 400 [unknown:8830] => 0 [ExifVersion] => version 2.21 [DateTimeOriginal] => 2010:09:03 10:55:58 [DateTimedigitized] => 2010:09:03 10:55:58 [ShutterSpeedValue] => 1/999 sec [ApertureValue] => f/5.6 [ExposureBiasValue] => 0 EV [MaxApertureValue] => f/5.7 [SubjectDistance] => 58.5 [MeteringMode] => Multi-Segment [Flash] => No Flash [FocalLength] => 800 mm [SubsecTimeOriginal] => 85 [SubsecTimeDigitized] => 85 [ColorSpace] => sRGB [ExifImageWidth] => 800 pixels [ExifImageHeight] => 476 pixels [FocalPlaneXResolution] => 3795.3488372093 [FocalPlaneYResolution] => 3904.3062200957 [FocalPlaneResolutionUnit] => Inch [CustomerRender] => 0 [ExposureMode] => 0 [WhiteBalance] => 0 [SceneCaptureMode] => 0 [unknown:a431] => 530302046 [unknown:a432] => 0 [unknown:a434] => EF800mm f/5.6L IS USM [FocalLength35mmEquiv] => 5379.7345724226 ) [IFD1NumTags] => 6 [IFD1] => Array ( [Compression] => Jpeg Compression [xResolution] => 72 dots per ResolutionUnit [yResolution] => 72 dots per ResolutionUnit [ResolutionUnit] => Inch [JpegIFOffset] => 874 [JpegIFByteCount] => 1810 ) )

Αndré

Replace
print_r($exifRawData);
with
$caption .= '<br />Daten taken: '.$exifRawData['SubIFD']['DateTimeOriginal']

and report if it works as expected. Maybe we have to change the formatting, but at first I'd like to know if it displays the date/time at all.

altenae

Yep that works.

Included the class="thumb_caption"

$caption .= '<span class="thumb_caption">' . '<br />Daten taken: '.$exifRawData['SubIFD']['DateTimeOriginal'] . '</span>';

The date format is now:

Daten taken: 2010:08:03 09:26:24

Should change to:

Date taken: Aug 03, 2010


altenae

Noticed one thing..

The date taken is not visible underneath an image which had not been viewed after the upgrade to cpg 1.5 or freshly uploaded and not viewed yet.

This is because the exif dat is stored in the table "exif" when the image is viewed only. (I think)

Is there a work around for this ?


Αndré

#10
Replace the whole code I gave you with
        if ($CONFIG['read_exif_data']) {
            $result = cpg_db_query("SELECT exifData FROM {$CONFIG['TABLE_EXIF']} WHERE pid = {$row['pid']}");
            if (!mysql_num_rows($result)) {
                include_once("include/exif_php.inc.php");
                $path_to_pic = $CONFIG['fullpath'] . $row['filepath'] . $row['filename'];
                $path_to_orig_pic = $CONFIG['fullpath'] . $row['filepath'] . $CONFIG['orig_pfx'] . $row['filename'];
                $metadata_path = file_exists($path_to_orig_pic) ? $path_to_orig_pic : $path_to_pic;
                $exif = exif_parse_file($metadata_path, $row['pid']);
                $result = cpg_db_query("SELECT exifData FROM {$CONFIG['TABLE_EXIF']} WHERE pid = {$row['pid']}");
            }
            if (mysql_num_rows($result) > 0) {
                $row2 = mysql_fetch_assoc($result);
                $exifRawData = unserialize($row2['exifData']);
                $date = explode(" ", $exifRawData['SubIFD']['DateTimeOriginal']);
                $date = explode(":", $date[0]);
                $timestamp = mktime(0, 0, 0, $date[1], $date[2], $date[0]);
                $caption .= '<span class="thumb_caption">' . '<br />Daten taken: '.localised_date($timestamp, $lang_date['album']).'</span>';
            }
            mysql_free_result($result);
        }

altenae

Will do some testing, but all seems to work perfect...

Thank you

Αndré

I just updated the above code (changed $row to $row2) as it overwrote some important data.

altenae


roaftech

Some interesting code there!

Just one minor point - this presupposes that the Exif date was correct when the photo was taken. If, for example, the camera battery is removed for charging, then it is important to reset the camera afterwards (speaking from (wife's) experience!). I found that it is very difficult to amend the date afterwards.

I prefer the approach of using one of the custom fields to store the photo date - a bit tedious when loading files but more reliable and easier to access afterwards. 
.
Steve Humphreys,
Help, Hope and Co-operation,
Asociatia Neemia, Dorohoi, Romania.
www.roaf.org/gallery