How do I add exif data to an image?

0 votes
asked Oct 23, 2008 by conroyp

On our site, we get a large amount of photos uploaded from various sources.

In order to keep the file sizes down, we strip all exif data from the source using mogrify:

mogrify -strip image.jpg

What we'd like to be able to do is to insert some basic exif data (Copyright Initrode, etc) back onto this new "clean" image, but I can't seem to find anything in the docs that would achieve this.

Has anybody any experience of doing this?

If it can't be done through imagemagick, a PHP-based solution would be the next best thing!

Thanks.

5 Answers

0 votes
answered Oct 23, 2008 by colin-pickard

Exiftool looks like it would be an exact match for you.

I haven't tried it but I'm now tempted to go and fix all my honeymoon photos which are marked 01/01/2074 because I forgot to reset the date after the batteries died.

0 votes
answered Oct 23, 2008 by mwilliams

Here's a PHP Exif Library that should do what you need.

The PHP Exif Library (PEL) lets you fully manipulate Exif (Exchangeable Image File Format) data. This is the data that digital cameras place in their images, such as the date and time, shutter speed, ISO value and so on.

Using PEL, one can fully modify the Exif data, meaning that it can be both read and written. Completely new Exif data can also be added to images. PEL is written completely in PHP and depends on nothing except a standard installation of PHP, version 5. PEL is hosted on SourceForge.

0 votes
answered Oct 23, 2008 by philho

I doubt you will gain lot of space by removing Exif information...

Anyway, I can be wrong, but Exif metadata belongs more to store technical (and contextual) information. For stuff like copyright, you should use IPTC instead.

That's something you can do, apparently, with ImageMagick: Write IPTC Data to Jpeg with ImageMagick.

0 votes
answered Oct 23, 2008 by ciaran

You can save a large amount of space, especially if you have a large number of images..

Add the following to text.txt (format of the IPTC tags taken from here):

2#110#Credit="My Company"
2#05#Object Name="THE_OBJECT_NAME"
2#55#Date Created="2011-02-03 12:45"
2#80#By-line="BY-LINE?"
2#110#Credit="The CREDIT"
2#115#Source="SOURCE"
2#116#Copyright Notice="THE COPYRIGHT"
2#118#Contact="THE CONTACT"
2#120#Caption="AKA Title"

Strip all existing exif data from the image

mogrify -strip image.jpg

Add the credit to your image

mogrify -profile 8BIMTEXT:text.txt image.jpg
0 votes
answered Oct 8, 2010 by bastiaan

on linux there is a program called jhead. It can add a minimal exif header with the command:

jhead -mkexif img.jpg

Welcome to Q&A, where you can ask questions and receive answers from other members of the community.
Website Online Counter

...