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:

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:

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);
        $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 
        echo "USER_COMMENT wird geschrieben<br>";
        $exif_entry = new PelEntryUserComment($USER_COMMENT);
        echo "MODEL wird geschrieben<br>";
        $exif_entry = new PelEntryAscii(PelTag::MODEL, $MODEL);
        echo "IMAGE_DESCRIPTION wird geschrieben<br>";
        $desc = new PelEntryAscii(PelTag::IMAGE_DESCRIPTION, $description);
        echo "GPS_VERSION_ID wird geschrieben<br>";
        $exif_entry = new PelEntryByte(PelTag::GPS_VERSION_ID,$GPS_VERSION_ID);
        echo "GPS_LATITUDE_REF wird geschrieben<br>";
        $exif_entry = new PelEntryAscii(PelTag::GPS_LATITUDE_REF, 
        echo "GPS_LATITUDE wird geschrieben<br>";
        $exif_entry = new PelEntryRational(PelTag::GPS_LATITUDE, $GPS_LATITUDE);
        echo "GPS_LONGITUDE_REF wird geschrieben<br>";
        $exif_entry4 = new PelEntryAscii(PelTag::GPS_LONGITUDE_REF, 

        echo "GPS_LONGITUDE wird geschrieben<br>";
        $exif_entry = new PelEntryRational(PelTag::GPS_LONGITUDE, 
        echo "GPS_ALTITUDE wird geschrieben<br>";
        $exif_entry = new PelEntryRational(PelTag::GPS_ALTITUDE, $GPS_ALTITUDE);
        echo "GPS_ALTITUDE_REF wird geschrieben<br>";
        $exif_entry = new PelEntryAscii(PelTag::GPS_ALTITUDE_REF, 
        $file = basename($filename);  
        file_put_contents("tagged_pics/".$file, $jpeg->getBytes());


Comment By: Nobody/Anonymous (nobody)
Date: 2007-10-18 07:28

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(

is right ;)

thx anyway.... btw, nice function, isnt it? ;)


Comment By: Nobody/Anonymous (nobody)
Date: 2007-10-18 05:09

Logged In: NO 

And i use EXIFReader to ckeck the Exif-Data in the Jpeg..

Best regards,



You can respond by visiting:

This 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 >>
PEL-devel mailing list

Reply via email to