Thanks Martin...I solved problem with your help. It realy works!!

For the other members, problem was adding DATE_TIME_ORIGINAL tag  and 
seting  value on file that does not have  any tags at all.

Following code is based on edit_description.php (great example of usage) 
which comes with Martin's pel:

$filename = '/srv/www/htdocs/lfa/albums/eto.jpg';  // <----SET YOUR 
$jpeg = $file = new PelJpeg($filename);
$exif = $jpeg->getExif();
     if ($exif == null)
               /* Ups, there is no APP1 section in the JPEG file.  This 
is where
                * the Exif data should be. */
               echo '<br>No APP1<br>';
            /* In this case we simply create a new APP1 section (a PelExif
                * object) and adds it to the PelJpeg object. */
               $exif = new PelExif();
           /* We then create an empty TIFF structure in the APP1 
section. */
               $tiff = new PelTiff();
               /* Surprice, surprice: Exif data is really just TIFF 
data!  So we
                * extract the PelTiff object for later use. */
           echo '<br>FOUND APP1<br>';
               $tiff = $exif->getTiff();

$ifd0 = $tiff->getIfd();
if ($ifd0 == null)
     /* No IFD in the TIFF data?  This probably means that the image
      * didn't have any Exif information to start with, and so an empty
      * PelTiff object was inserted by the code above.  But this is no
      * problem, we just create and inserts an empty PelIfd object. */
     echo '<br>No IFD found, adding new<br>';
     $ifd0 = new PelIfd(PelIfd::IFD0);

$ifd1 = $ifd0->getSubIfd(PelIfd::EXIF);
if ($ifd1 == null)
   echo '<br> NO SUBIFD...ADDING<br>';
   $sub_exif = new PelIfd(PelIfd::EXIF);
   $ifd1 = $ifd0->getSubIfd(PelIfd::EXIF);
$datum = gmmktime(0,0,0,10,3,1975); //make timestamp
$date = $ifd1->getEntry(PelTag::DATE_TIME_ORIGINAL);

if ($date == null)
           echo '<br>NO DATE_TIME_ORIGINAL... ADDINGi<br>';
           $date = new PelEntryTime(PelTag::DATE_TIME_ORIGINAL,$datum);
                 echo '<br>UPDATING FIELD...<br> ';
       /* The description is simply updated with the new description. */

$file->getBytes());  // <---- PUT YOUR NEW FILENAME HERE

SF.Net email is sponsored by:
Check out the new Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
PEL-devel mailing list

Reply via email to