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:
<?php
require_once('pel/PelJpeg.php');
require_once('pel/PelTiff.php');
$filename = '/srv/www/htdocs/lfa/albums/eto.jpg'; // <----SET YOUR
FILENAME HERE
$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();
$jpeg->setExif($exif);
/* We then create an empty TIFF structure in the APP1
section. */
$tiff = new PelTiff();
$exif->setTiff($tiff);
}
else
{
/* 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);
$tiff->setIfd($ifd0);
}
$ifd1 = $ifd0->getSubIfd(PelIfd::EXIF);
if ($ifd1 == null)
{
echo '<br> NO SUBIFD...ADDING<br>';
$sub_exif = new PelIfd(PelIfd::EXIF);
$ifd0->addSubIfd($sub_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);
$ifd1->addEntry($date);
}
else
{
echo '<br>UPDATING FIELD...<br> ';
/* The description is simply updated with the new description. */
$date->setValue($datum);
}
file_put_contents('/srv/www/htdocs/lfa/albums/test.jpg',
$file->getBytes()); // <---- PUT YOUR NEW FILENAME HERE
?>
-------------------------------------------------------------------------
SF.Net email is sponsored by:
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
PEL-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pel-devel