Setting Exif, IPTC, XMP etc descriptions all at the same time

Started by Archive, May 12, 2010, 08:54:16 AM

Previous topic - Next topic

Archive

[Originally posted by angelblue01 on 2008-03-08 20:53:21-08]

I dual-boot openSUSE Linux and Windows Vista.

Although normally I hate using the commandline I found exiftool really useful.

I wrote myself a shellscript that would set the exif description, IPTC caption, exifd description,  image comment, XMP description to user inputed text from the bash terminal.

I also set the date fields for those metadata to the modified date.

Here is my script

---


#! /bin/sh
#sets date and time for JPEG photos

echo "Enter description of photo"
read namep
# set the description on user input

echo "Enter file name"
read namef
# set the file name based on user input

echo "Time being entered automatically..."

# exiftool must be installed

#sets preserves file time the name and date for JIFF comment, exif, IPTC, exififd, xmp
exiftool -P -comment="$namep" -exif:ImageDescription="$namep" -exififd:usercomment="$namep" '-IPTC:Caption-Abstract= $namep' -xmp:description="$namep" -exif:ModifyDate=`date --rfc-3339=date --reference=$namef` -iptc:datecreated=`date --reference=$namef +%Y%m%d` -exififd:modifydate=`date --rfc-3339=date --reference=$namef` -xmp:date=`date --rfc-3339=date --reference=$namef` "$namef"


---

But when I run the script it seems to run fine:


thomas@THOMASPC:~> cd Desktop
thomas@THOMASPC:~/Desktop> sh savedescpic.sh
Enter description of photo
Test description
Enter file name
/home/thomas/Desktop/IMG_2018.jpg
Time being entered automatically...
    1 image files updated


When I look at the tags though it has this:


thomas@THOMASPC:~/Desktop> exiftool -a -u -g1  IMG_2018.jpg
---- ExifTool ----
ExifTool Version Number         : 7.19
---- File ----
File Name                       : IMG_2018.jpg
Directory                       : .
File Size                       : 697 kB
File Modification Date/Time     : 2007:07:04 13:36:07
File Type                       : JPEG
MIME Type                       : image/jpeg
Exif Byte Order                 : Little-endian (Intel)
Comment                         : Test description
Image Width                     : 2048
Image Height                    : 1536
Encoding Process                : Baseline DCT, Huffman coding
Bits Per Sample                 : 8
Color Components                : 3
Y Cb Cr Sub Sampling            : YCbCr4:2:2 (2 1)
---- IFD0 ----
Image Description               : Test description
Make                            : Canon
Camera Model Name               : Canon PowerShot A75
Orientation                     : Horizontal (normal)
X Resolution                    : 180
Y Resolution                    : 180
Resolution Unit                 : inches
Modify Date                     : 2007:07:04 00:00:00
Y Cb Cr Positioning             : Centered
---- ExifIFD ----
Modify Date                     : 2007:07:04 00:00:00
Exposure Time                   : 1/1000
F Number                        : 4.5
Exif Version                    : 0220
Date/Time Original              : 2007:07:04 12:36:07
Create Date                     : 2007:07:04 12:36:07
Components Configuration        : YCbCr
Compressed Bits Per Pixel       : 3
Shutter Speed Value             : 1/1002
Aperture Value                  : 4.5
Exposure Compensation           : 0
Max Aperture Value              : 2.8
Metering Mode                   : Multi-segment
Flash                           : Auto, Did not fire
Focal Length                    : 5.4 mm
User Comment                    : Test description
Flashpix Version                : 0100
Color Space                     : sRGB
Exif Image Width                : 2048
Exif Image Height               : 1536
Focal Plane X Resolution        : 9846.153846
Focal Plane Y Resolution        : 9846.153846
Focal Plane Resolution Unit     : inches
Sensing Method                  : One-chip color area
File Source                     : Digital Camera
Custom Rendered                 : Normal
Exposure Mode                   : Auto
White Balance                   : Auto
Digital Zoom Ratio              : 1
Scene Capture Type              : Standard
---- Canon ----
Macro Mode                      : Normal
Self Timer                      : Off
Quality                         : Fine
Canon Flash Mode                : Red-eye reduction (Auto)
Continuous Drive                : Single
Focus Mode                      : Single
Record Mode                     : JPEG
Canon Image Size                : Large
Easy Mode                       : Full auto
Digital Zoom                    : None
Contrast                        : Normal
Saturation                      : Normal
Sharpness                       : 0
Camera ISO                      : Auto
Metering Mode                   : Evaluative
Focus Range                     : Auto
AF Point                        : Auto AF point selection
Canon Exposure Mode             : Easy
Lens Type                       : Unknown (-1)
Long Focal                      : 16.21875 mm
Short Focal                     : 5.40625 mm
Focal Units                     : 32
Max Aperture                    : 2.9
Min Aperture                    : 8
Flash Bits                      : (none)
Focus Continuous                : Single
AE Setting                      : Normal AE
Zoom Source Width               : 2048
Zoom Target Width               : 2048
Spot Metering Mode              : Center
Photo Effect                    : Off
Manual Flash Output             : n/a
Focal Type                      : Zoom
Focal Length                    : 5.40625 mm
Focal Plane X Size              : 5.41 mm
Focal Plane Y Size              : 4.04 mm
Canon Flash Info                : 1024 0 0 0
Auto ISO                        : 100
Base ISO                        : 50
Measured EV                     : 10.28
Target Aperture                 : 4.5
Target Exposure Time            : 1/1002
Exposure Compensation           : 0
White Balance                   : Auto
Slow Shutter                    : Off
Shot Number In Continuous Burst : 0
Optical Zoom Code               : 0
Flash Guide Number              : 0
Flash Exposure Compensation     : 0
Auto Exposure Bracketing        : Off
AEB Bracket Value               : 0
Control Mode                    : Camera Local Control
Focus Distance Upper            : 16.14
Focus Distance Lower            : 0
F Number                        : 4.3
Exposure Time                   : 1/1024
Bulb Duration                   : 0
Camera Type                     : Compact
Auto Rotate                     : None
ND Filter                       : Off
Self Timer 2                    : 0
Flash Output                    : 0
Canon 0x0000                    : 0 0 0 0 0 0
Canon 0x0000                    : 0 0 0 0
Num AF Points                   : 9
Valid AF Points                 : 9
Canon Image Width               : 2048
Canon Image Height              : 1536
AF Image Width                  : 2048
AF Image Height                 : 256
AF Area Width                   : 369
AF Area Height                  : 42
AF Area X Positions             : -370 0 370 -370 0 370 -370 0 370
AF Area Y Positions             : -48 -48 -48 0 0 0 48 48 48
AF Points In Focus              : 4
Primary AF Point                : 4
Thumbnail Image Valid Area      : 0 0 0 0
Canon Image Type                : IMG:PowerShot A75 JPEG
Canon Firmware Version          : Firmware Version 1.01
File Number                     : 145-4579
Owner Name                      :
Canon Model ID                  : PowerShot A75
Canon 0x0017                    : 0
Canon 0x0018                    : 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0[...]
Canon 0x0019                    : 1
Date Stamp Mode                 : Off
---- InteropIFD ----
Interoperability Index          : R98 - DCF basic file (sRGB)
Interoperability Version        : 0100
Related Image Width             : 2048
Related Image Height            : 1536
---- IFD1 ----
Compression                     : JPEG (old-style)
X Resolution                    : 180
Y Resolution                    : 180
Resolution Unit                 : inches
Thumbnail Offset                : 1842
Thumbnail Length                : 3773
---- IPTC ----
Date Created                    : 2007:07:04
Caption-Abstract                :  $namep
Application Record Version      : 4
---- XMP-dc ----
Date                            : 2007:07:04
Description                     : Test description
---- Composite ----
Aperture                        : 4.5
Drive Mode                      : Single-frame shooting
Flash                           : Off
ISO                             : 50
Image Size                      : 2048x1536
Lens                            : 5.4 - 16.2 mm
Scale Factor To 35 mm Equivalent: 6.4
Shooting Mode                   : Full auto
Shutter Speed                   : 1/1000
Thumbnail Image                 : (Binary data 3773 bytes, use -b option to extract)
Circle Of Confusion             : 0.005 mm
Field Of View                   : 54.9 deg
Focal Length                    : 5.4 mm (35 mm equivalent: 34.6 mm)
Hyperfocal Distance             : 1.39 m
Lens                            : 5.4 - 16.2 mm (35 mm equivalent: 34.6 - 103.9 mm)
Light Value                     : 15.3


it literally set the IPTC caption-abstract to $namef

It took a great deal of trouble to get the proper formats for all the fields that I'm working with correct by hand and now it breaks in this script.

Please let me know what I'm doing wrong.

I'd also like to write a similiar script for Windows so I need to know DOS batch file variables to use.

Thanks!

Archive

[Originally posted by exiftool on 2008-03-09 00:09:57-08]

If you want the unix shell to substitute $var expressions in
the command, they should be in double quotes (or backticks
as you have also used, but this is more advanced than most
users would get) as all of your other arguments, not single
quotes as you have used for caption-abstract.  The shell
does not interpolate in single quotes as it does in double
quotes.

For Windows, double quotes must be used, and the batch
variables look like %1, etc for input arguments, and maybe
something like %var% for other variables, although I haven't
written a .bat file since my old DOS days, so my memory may
be off here.

- Phil

Archive

[Originally posted by exiftool on 2008-03-09 00:17:44-08]

I would also maybe suggest simplifying your command in the sh script
a bit using a variable to store the date:

Code:
mydate=`date --rfc-3339=date --reference=$namef`
exiftool ... -exif:ModifyDate="$mydate"  -xmp:date="$mydate" ...

Also, I assume you have your reasons for duplicating the EXIF ModifyDate
in the ExifIFD, but by the EXIF specification, this should only be written
in IFD0 (as it will be with -Exif:ModifyDate).  But I have seen other
software do this too.

- Phil