Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

How do I write image exif data?



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

5+ Year Member Top Contributors Of The Month

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.

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

All that is showing is:


[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?


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

10+ Year Member

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):


PEL supports reading and writing of EXIF data.

-- Roger

Featured Threads

Hot Threads This Week

Hot Threads This Month