Advanced search  

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

Pages: [1]   Go Down

Author Topic: Date Taken underneath thumbnail  (Read 5758 times)

0 Members and 1 Guest are viewing this topic.

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Date Taken underneath thumbnail
« on: November 21, 2011, 06:59:53 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Date Taken underneath thumbnail
« Reply #1 on: November 22, 2011, 05:04:20 pm »

I just tried to find a quick solution by adding
Code: [Select]
        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
Code: [Select]
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
Code: [Select]
        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.
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #2 on: November 22, 2011, 05:26:39 pm »

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.
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #3 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.
I am interested in the field "Date Digitized" onl from the exif info.

Edward
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #4 on: November 22, 2011, 05:51:03 pm »

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
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Date Taken underneath thumbnail
« Reply #5 on: November 22, 2011, 08:04:38 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
this isn't the final solution but displays the fetched EXIF data


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).
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #6 on: November 22, 2011, 08:20:50 pm »

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 ) )
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Date Taken underneath thumbnail
« Reply #7 on: November 23, 2011, 03:49:15 pm »

Replace
Code: [Select]
print_r($exifRawData);with
Code: [Select]
$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.
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #8 on: November 23, 2011, 03:58:14 pm »

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

Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #9 on: November 23, 2011, 04:18:11 pm »

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 ?

Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Date Taken underneath thumbnail
« Reply #10 on: November 23, 2011, 04:57:30 pm »

Replace the whole code I gave you with
Code: [Select]
        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);
        }
« Last Edit: November 24, 2011, 11:53:57 am by Αndré »
Logged

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #11 on: November 23, 2011, 05:10:31 pm »

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

Thank you
Logged

Αndré

  • Administrator
  • Coppermine addict
  • *****
  • Country: de
  • Offline Offline
  • Gender: Male
  • Posts: 15764
Re: Date Taken underneath thumbnail
« Reply #12 on: November 24, 2011, 11:54:57 am »

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

altenae

  • Coppermine frequent poster
  • ***
  • Offline Offline
  • Posts: 254
Re: Date Taken underneath thumbnail
« Reply #13 on: November 24, 2011, 03:23:30 pm »

Works !!!
Logged

roaftech

  • Coppermine novice
  • *
  • Country: ro
  • Offline Offline
  • Gender: Male
  • Posts: 24
    • Romanian Aid Foundation
Re: Date Taken underneath thumbnail
« Reply #14 on: January 13, 2012, 05:19:52 pm »

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. 
Logged
.
Steve Humphreys,
Help, Hope and Co-operation,
Asociatia Neemia, Dorohoi, Romania.
www.roaf.org/gallery
Pages: [1]   Go Up
 

Page created in 0.08 seconds with 20 queries.