homepage Welcome to WebmasterWorld Guest from 54.226.0.225
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
How do I write image exif data?
ocon




msg:4494396
 5:15 pm on Sep 12, 2012 (gmt 0)

I am using PHP Version 5.3.14 compiled with ImageMagick 6.7.6-3.

I would eventually like to geotag the thumbnails my script creates using the correct exif data, but right now I am having a very difficult time just writing any exif data.

// The following is directly from PHP's website
$image = new Imagick();
$image->newImage(300, 200, "black");
$image->setImageProperty('Exif:Make', 'Imagick');
echo $image->getImageProperty('Exif:Make'); // The page does display "Imagick"

// Now I'm writing the image I just created to my hard drive and freeing my memory.
$image->writeImage("test.jpg");
$image->destroy();

// Now I'm displaying the exif data of the saved image
$exif = exif_read_data("test.jpg", 0, true);
print_r($exif);


All that is showing is:

Imagick

Array
(
[FILE] => Array
(
[FileName] => test.jpg
[FileDateTime] => 1347469943
[FileSize] => 398
[FileType] => 2
[MimeType] => image/jpeg
[SectionsFound] =>
)

[COMPUTED] => Array
(
[html] => width="300" height="200"
[Height] => 200
[Width] => 300
[IsColor] => 0
)

)

What am I doing wrong? How can I properly add exif data to my images?

 

jadebox




msg:4494901
 9:38 pm on Sep 13, 2012 (gmt 0)

In spite of the examples in the documentation, I don't think that ImageMagik really writes EXIF data to the image. In your example, it's just saving a loading a property with "Exif" in the name, but not actually saving it in EXIF format.

Look at the PHP EXI Library (PEL):

[lsolesen.github.com...]

PEL supports reading and writing of EXIF data.

-- Roger

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved