Annotating photographs

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
schievelbein
Posts: 12
Joined: 2013-10-24T11:34:48-07:00
Authentication code: 6789

Annotating photographs

Post by schievelbein »

I am using ImageMagick 6.7.7-10 on Linux Mint 17 to annotate many 1000s of genealogy photographs.
I have developed the following script, but it still has a bunch of problems that I am hoping someone can help with.

Code: Select all

cwidth=`identify -format "%[fx:w]" $1`;
cheight=`identify -format "%[fx:h/20]" $1`;
cdate=`identify -format %[Date:exif:DateTimeOriginal] $1`;
cdesc=`identify -format %[IPTC:2:120] $1`;
convert $1 -gravity South -splice 0x${cheight} annotated_$1
convert -background white -fill black -gravity center -size ${cwidth}x${cheight} caption:"$cdate $cdesc" annotated_$1 +swap -gravity south -composite annotated_$1
The code takes the DATE and COMMENT from a jpg and uses it to create an ANNOTATION at the bottom of the photo on an extended canvas area.
The problems are:
1. The current script sometimes takes minutes to run, is there anything in my script that I could change to speed it up?
2. Is there any way to use Mogrify instead of convert so that it will overwrite the file and I do not have to do renames?
3. Is there any way to make all of this one command so that I could use it within FotoXX and similar interfaces?

Any and all suggestions or criticism is welcomed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Annotating photographs

Post by fmw42 »

6.7.7.10 is ancient (140 versions old). upgrade.

You cannot make it all one command. All the variable calculations can be made into one command. The convert commands can be combined by using parenthesis processing. See http://www.imagemagick.org/Usage/basics/#parenthesis.

Mogrify takes one image and makes one output only for each image in the folder. However, one can do composites using -draw, but the image must exist already. You cannot use parentheses in mogrify. See http://www.imagemagick.org/Usage/basics ... fy_compose. So it would only be of use if you have the same overlay image (or the same background image) for every image in your folder.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Annotating photographs

Post by snibgo »

You run identify four times, reading the image file four times. You could do this just once:

Code: Select all

read cwidth cheight cdate cdesc <<< $( identify -format "%w %[fx:h/20] %[Date:exif:DateTimeOriginal] %[IPTC:2:120]" %1 )
snibgo's IM pages: im.snibgo.com
Post Reply