Support Requests item #1815728, was opened at 2007-10-18
14:05
Message generated for change (Comment added) made by
mgeisler
You can respond by visiting:
https://sourcefo
rge.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: Closed
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: Martin Geisler (mgeisler)
Date: 2007-10-19 08:08
Message:
Logged In: YES
user_id=1264592
Originator: NO
Thanks, you can attach them to this tracker item, no
problem.
Please try to follow the style from the other files in the
examples
folder. The examples there are all command line based
(simply because those
are the simplest to write for me). But it would be great to
have some
web-based examples too! Upload what you've got, and then we
can take a look
at it.
------------------------------------------------------------
----------
Comment By: Andac (aandac)
Date: 2007-10-18 21:58
Message:
Logged In: YES
user_id=1916459
Originator: NO
Hi, i'd love to contribute to your project!
Where can i upload the revisited 2 functions?
best regards,
Andac
------------------------------------------------------------
----------
Comment By: Martin Geisler (mgeisler)
Date: 2007-10-18 20:10
Message:
Logged In: YES
user_id=1264592
Originator: NO
Nice that figured it out by yourself -- the rationals are
not the easies
class to work with.
The script looks good, I just have one comment: the if
statement is not
needed since an empty PelTiff object contains no PelIfd
object to begin
with. So the test is always true and can be skipped.
I'll close the request now -- please drop by on the
pel-devel mailing list
if you have suggestions as to how we can make PEL easier to
use. Maybe we
should package your script up as an example? It would be
great if you could
turn it into a self-contained unit (I saw it uses a
convertGps function)
then I would like to include it.
Also, please note that I have never really tested the GPS
tags myself
since I don't have any GPS equipment. So any help there is
much
appreciated.
------------------------------------------------------------
----------
Comment By: Nobody/Anonymous (nobody)
Date: 2007-10-18 16: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_LAT
ITUDE[2],1));
is right ;)
thx anyway.... btw, nice function, isnt it? ;)
------------------------------------------------------------
----------
Comment By: Nobody/Anonymous (nobody)
Date: 2007-10-18 14:09
Message:
Logged In: NO
And i use EXIFReader to ckeck the Exif-Data in the Jpeg..
Best regards,
Andac
aandac gmx.de
------------------------------------------------------------
----------
You can respond by visiting:
https://sourcefo
rge.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
PEL-devel lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/pel-devel
|