Support Requests item #1815728, was opened at 2007-10-18 05:05
Message generated for change (Comment added) made by nobody
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=650323&aid=1815728&group_id=108380
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: None
Group: None
Status: Open
Priority: 5
Private: No
Submitted By: Nobody/Anonymous (nobody)
Assigned to: Nobody/Anonymous (nobody)
Summary: adding EXIF Information from scratch
Initial Comment:
Hi,
I wrote this function, adding EXIF Information from the scratch to a JPG-Image.
Unfortunately in the second GPS entry, the minutes and seconds are missing. If
longitude is the second then its missing there, if i switch their places its
missing in latitude? It doesnt make any sense, so ... well i'm asking for help
here :)
Here's the function (with german comments):
function add_EXIFinfo(
$filename = "filename.jpg Default",
$description ="DESCRIPTION Default",
$USER_COMMENT ="USER_COMMENT Default",
$MODEL ="MODEL Default",
$GPS_VERSION_ID ="123",
$GPS_LONGITUDE = 0,
$GPS_LATITUDE = 0,
$GPS_LONGITUDE_REF = "E",
$GPS_LATITUDE_REF = "N",
$GPS_ALTITUDE = array(0, 0, 0),
$GPS_ALTITUDE_REF = 0) {
$GPS_LONGITUDE = convertGps($GPS_LONGITUDE);
$GPS_LATITUDE = convertGps($GPS_LATITUDE);
$jpeg = new PelJpeg($filename); //Ein PelJpeg Objekt wird erstellt (mit
dem gegebenen JPG)
$exif = new PelExif(); //Exif Objekt wird erstellt
$jpeg->setExif($exif); //Exif Objekt wird dem JPG hinzugefügt
$tiff = new PelTiff(); // Tiff Objekt wird erzeugt (Tiff Objekt enthält
exif info)
$exif->setTiff($tiff); //Dem Exif-Objekt wird das Tiff Objekt zugewiesen
$ifd0 = $tiff->getIfd(); //erste Exif-Info wird aus dem tiff Obj
herausgelesen ( müsste "null" sein)
if ($ifd0 == null) {
$ifd0 = new PelIfd(PelIfd::IFD0);
$tiff->setIfd($ifd0);
}
$GPSSubIFD = new PelIfd(PelIfd::GPS); //SubIFD für GPS-Informationen
wird erstellt.
$ifd0->addSubIfd($GPSSubIFD); //dem Ifd0 wird GPS sub IFD hinzugefügt
$EXIFSubIFD = new PelIfd(PelIfd::EXIF); //SubIFD für EXIF-Informationen
wird erstellt.
$ifd0->addSubIfd($EXIFSubIFD); //dem Ifd0 wird EXIF sub IFD hinzugefügt
$INTOSubIFD = new PelIfd(PelIfd::INTEROPERABILITY); //SubIFD für
INTEROPERABILITY-Informationen wird erstellt.
$ifd0->addSubIfd($INTOSubIFD); //dem Ifd0 wird INTEROPERABILITY sub IFD
hinzugefügt
echo "USER_COMMENT wird geschrieben<br>";
$exif_entry = new PelEntryUserComment($USER_COMMENT);
$ifd0->addEntry($exif_entry);
echo "MODEL wird geschrieben<br>";
$exif_entry = new PelEntryAscii(PelTag::MODEL, $MODEL);
$ifd0->addEntry($exif_entry);
echo "IMAGE_DESCRIPTION wird geschrieben<br>";
//IMAGE_DESCRIPTION
$desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description);
$ifd0->addEntry($desc);
echo "GPS_VERSION_ID wird geschrieben<br>";
$exif_entry = new PelEntryByte(PelTag::GPS_VERSION_ID,$GPS_VERSION_ID);
$GPSSubIFD->addEntry($exif_entry);
echo "GPS_LATITUDE_REF wird geschrieben<br>";
$exif_entry = new PelEntryAscii(PelTag::GPS_LATITUDE_REF,
$GPS_LATITUDE_REF);
$GPSSubIFD->addEntry($exif_entry);
echo "GPS_LATITUDE wird geschrieben<br>";
$exif_entry = new PelEntryRational(PelTag::GPS_LATITUDE, $GPS_LATITUDE);
print_r($GPS_LATITUDE);
$GPSSubIFD->addEntry($exif_entry);
echo "GPS_LONGITUDE_REF wird geschrieben<br>";
$exif_entry4 = new PelEntryAscii(PelTag::GPS_LONGITUDE_REF,
$GPS_LONGITUDE_REF);
$GPSSubIFD->addEntry($exif_entry4);
echo "GPS_LONGITUDE wird geschrieben<br>";
$exif_entry = new PelEntryRational(PelTag::GPS_LONGITUDE,
$GPS_LONGITUDE);
print_r($GPS_LONGITUDE);
$GPSSubIFD->addEntry($exif_entry);
echo "GPS_ALTITUDE wird geschrieben<br>";
$exif_entry = new PelEntryRational(PelTag::GPS_ALTITUDE, $GPS_ALTITUDE);
$GPSSubIFD->addEntry($exif_entry);
echo "GPS_ALTITUDE_REF wird geschrieben<br>";
$exif_entry = new PelEntryAscii(PelTag::GPS_ALTITUDE_REF,
$GPS_ALTITUDE_REF);
$GPSSubIFD->addEntry($exif_entry);
$file = basename($filename);
file_put_contents("tagged_pics/".$file, $jpeg->getBytes());
}
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2007-10-18 07:28
Message:
Logged In: NO
ok.. got it myself:
$exif_entry = new PelEntryRational(PelTag::GPS_LATITUDE, $GPS_LATITUDE);
is wrong,
$exif_entry = new PelEntryRational(PelTag::GPS_LATITUDE, array(
$GPS_LATITUDE[0],1),array($GPS_LATITUDE[1],1),array($GPS_LATITUDE[2],1));
is right ;)
thx anyway.... btw, nice function, isnt it? ;)
----------------------------------------------------------------------
Comment By: Nobody/Anonymous (nobody)
Date: 2007-10-18 05:09
Message:
Logged In: NO
And i use EXIFReader to ckeck the Exif-Data in the Jpeg..
Best regards,
Andac
[EMAIL PROTECTED]
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=650323&aid=1815728&group_id=108380
-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems? Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
PEL-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pel-devel