Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k

Message Too Old, No Replies

inserting exif data into images



8:53 am on Apr 9, 2010 (gmt 0)

5+ Year Member

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.


1:14 pm on Apr 9, 2010 (gmt 0)

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

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


i like this reference


7:15 pm on Apr 12, 2010 (gmt 0)

5+ Year Member

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.


7:54 pm on Apr 12, 2010 (gmt 0)

10+ Year Member

(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.


9:54 pm on Apr 12, 2010 (gmt 0)

5+ Year Member

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.


12:21 am on Apr 13, 2010 (gmt 0)

10+ Year Member

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."



8:15 pm on Apr 18, 2010 (gmt 0)

5+ Year Member

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

Featured Threads

Hot Threads This Week

Hot Threads This Month