homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor 2014
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

inserting exif data into images

5+ Year Member

Msg#: 4112836 posted 8:53 am on Apr 9, 2010 (gmt 0)

I'm using the GD library to resize digital camera images. After the resizing, all previous EXIF data disappears from the images.

I know how to read the data with exif_read_data and I've stored all exif data from the images before resizing them in a textfile and would now need to insert it back into the resized images.

What can I use to do this? I can't find anything in the documentation about this, only how to retrieve the data but not how to write the data itto an image.



WebmasterWorld Administrator jatar_k us a WebmasterWorld Top Contributor of All Time 10+ Year Member

Msg#: 4112836 posted 1:14 pm on Apr 9, 2010 (gmt 0)

I searched for "php write exif" and found a couple things, try this one


i like this reference


5+ Year Member

Msg#: 4112836 posted 7:15 pm on Apr 12, 2010 (gmt 0)

I already tried PEL, it's not working for me.

I'm getting an error message "Fatal error: Call to a member function getTiff() on a non-object in..." when I try to edit a description (taken from an example in the documentation) of an image processed with GD.

It works fine though on images that come straight from the camera and that have not been processed with GD.


10+ Year Member

Msg#: 4112836 posted 7:54 pm on Apr 12, 2010 (gmt 0)

(hello jatar)

Unlike IPTC, EXIF was (still is?) a write-once-read-only-format. There is a class (#1042) in PHPclasses for EXIF modification but I've not seen anyone say that it works.

FWIW: Here's a note from php.net GD Manual comments dated Dec 2008.

You know, maybe this goes without saying, but I thought I would drop a note in here. When developing code to resize images, it is best not to use GD. When using the current GD methodologies, you are reading content from an image and manipulating it. By then writing that content to a brand new file, you are losing the EXIF data.

For purposes when you want to retain EXIF data, it is recommended that you compile in and use the PECL Imagick extension. It has great resizing methods built right in and the EXIF data is retained.


5+ Year Member

Msg#: 4112836 posted 9:54 pm on Apr 12, 2010 (gmt 0)

thanks for the reply

unfortunately, I cannot use the PECL Imagick extension because it breaks dcf compatibility

the whole reason why I use GD is because it keeps the images dcf compatible. everything else I've tried to far for resizing photos will result in an error on my digital camera when I place them back on the camera

EXIF is definitely not read only. I have been able to edit EXIF data. I just have this problem with editing it after using GD to resize the photo.


10+ Year Member

Msg#: 4112836 posted 12:21 am on Apr 13, 2010 (gmt 0)

My experience has been primarily with IPTC data but from what I'm seeing out there, PEL seems to be the only option with GD.

Part of the reason for the lack of apps may be that EXIF is apparently a standard in flux. As I understand it, the EXIF standard was originally set up as read-only. Some apps, like MS Expression Media, choose to follow the standard. Geo-tagging, in particular, has called for work-arounds.

"EXIF data is typically considered read-only. Fortunately, the Annotations section geocoding fields have been extended to include Latitude and Longitude. This allows you to correct or add GPS locations to your existing photos."



5+ Year Member

Msg#: 4112836 posted 8:15 pm on Apr 18, 2010 (gmt 0)

well I've given up trying it in PHP. I'm doing it semi-automatically with Attribute Magic Pro now.

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