Using EXIF on my home IT

I need to write a script that installs author and copyright facts into my pictures.  The EXIF libraries are what I need. I’ll also need a scripting language; I used cygwin bash as my prototyping environment.

http://www.sno.phy.queensu.ca/~phil/exiftool/ is the basic tool with Command Line Interface but it can be included in the cygwin download, although this is hosted at http://libexif.sourceforge.net/docs.html, so could be different tools.

http://linux.die.net/man/1/exiftool, the man page.


The following content applies to the cygwin download.

I want a script that will add an Artist and Copyright statement to a variable number of (my pictures).

for tags in Artist Copyright ; do
    exif -l ${filename} | grep $TAGNAME
done

will give me the Hex Codes, for where they’re needed

exif -s --tag=Artist --ifd=0 ${filename}

gives the description, which in the case of Copyright says,

Tag 'Copyright' (0x8298, 'Copyright'): Copyright information. In this standard the tag is used to indicate both the photographer and editor copyrights. It is the copyright notice of the person or organisation claiming rights to the image. The Interoperability copyright statement including date and rights should be written in this field; e.g., "Copyright, John Smith, 19xx. All rights reserved.". In this standard the field records both the photographer and editor copyrights, with each recorded in a separate part of the statement. When there is a clear distinction between the photographer and editor copyrights, these are to be written in the order of photographer followed by editor copyright, separated by NULL (in this case, since the statement also ends with a NULL, there are two NULL codes) (see example 1). When only the photographer is given, it is terminated by one NULL code (see example 2). When only the editor copyright is given, the photographer copyright part consists of one space followed by a terminating NULL code, then the editor copyright is given (see example 3). When the field is left blank, it is treated as unknown.

I have inserted a Copyright statement into a picture and this is the output display, created by the following command

exif -ifd=0 --tag=Copyright --set-value="Dave Levy 2013 CC BY-SA" waterloo.jpg
EXIF tags in 'waterloo.jpg.modified.jpeg' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag                 |Value
--------------------+----------------------------------------------------------
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Date and Time       |2015:03:04 11:33:28
YCbCr Positioning   |Centred
Copyright           |Dave Levy 2013 CC BY-SA (Photographer) - [None] (Editor)
Exif Version        |Exif Version 2.1
Components Configura|Y Cb Cr -
FlashPixVersion     |FlashPix Version 1.0
Colour Space        |Uncalibrated
Pixel X Dimension   |0
Pixel Y Dimension   |0
--------------------+----------------------------------------------------------

this was but I am not sure how to write the NULL character into the command line. Can this be done from the command line? Not sure how to present a string containing spaces to a shell script command; the interpreter removes the enclosing quotes.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *