André Mantz <[EMAIL PROTECTED]> writes:

> Hello,
> sorry about my bad english, I hope you understand me.

No problem, I'm not a native speaker either, and I think your English is

> I tried to add tags for the gps-coordinates to a jpeg-file with existing
> Exif-data.
> This is, what I do (e.g. LAT 52° 30’ 45.0’’ and LON 9° 15’ 30.0’’):
> $jpeg = new PelJpeg($filename);
> $tiff = $exif->getTiff();
> $ifd0 = $tiff->getIfd();
> $desc1 = new PelEntryRational(PelTag::GPS_LATITUDE, array(52,1),
> array(30,1), array(45,1));
> $ifd0->addEntry($desc1);
> $desc2 = new PelEntryRational(PelTag::GPS_LONGITUDE, array(9,1),
> array(15,1), array(30,1));
> $ifd0->addEntry($desc2);
> $desc3 = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, 'only for test');
> $ifd0->addEntry($desc3);
> file_put_contents($new_filename, $jpeg->getBytes());
> After processing the script (with no errors), there a no gps-tags in
> the file. If read the exif with:
> $jpeg = new PelJpeg($filename);
> $tiff = $exif->getTiff();
> $ifd0 = $tiff->getIfd();
> $lat = $ifd0->getEntry(PelTag::GPS_LATITUDE);
> $lon = $ifd0->getEntry(PelTag::GPS_LONGITUDE);
> $test = $ifd0->getEntry(PelTag:: IMAGE_DESCRIPTION);
> The result is: $lat and $lon both are null, but $test is filled correctly.
> What is my fault?

It is not so much your fault but PEL's... you are adding the entries to
IFD0, but GPS related tags must be added to a GPS sub-IFD of the IFD0 --
not my idea... but that's the Exif standard :-)

This post has the solution:

namely code like this:

  $gps = new PelIfd(PelIfd::GPS);
  $lat = new PelEntryRational(PelTag::GPS_LATITUDE,

It is of course a bug that PEL accepts the latitude and longitude tags
in IFD0. I have just committed a fix for this as revision 510. I have
only changed PelIfd.php and you can get a copy of it here:

Could you please check that it correctly catches your mistake. It should
throw an exception when you try to add the GPS tags in IFD0.

Martin Geisler

VIFF (Virtual Ideal Functionality Framework) brings easy and efficient
SMPC (Secure Multi-Party Computation) to Python. See:

Attachment: pgpBP7Whg7oVu.pgp
Description: PGP signature

This email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
PEL-devel mailing list

Reply via email to