Annotating photos with metadata -SOLVED

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?".
schievelbein
Posts: 12
Joined: 2013-10-24T11:34:48-07:00
Authentication code: 6789

Re: Annotating photos with metadata

Post by schievelbein »

Here is some clarification.
I am trying to write a script to run after I scan each image and put the meta-data into THOUSANDS of photos I am scanning.
When I right click on an image, and select Annotate, it runs my script Annotate with the filename as the parameter.
Here is my script that I currently run, that has to be edited for every single file:

Code: Select all

convert "input.jpg" \( -clone 0 -size 1200 -delete 0 -background black -gravity center -pointsize 20 -fill White caption:"This is a the meta-comment that is pulled from the photo and I do not want to have to cut and paste for every photo" -trim \) -append "annotated.jpg"
and here is how I would like to make the script general, but I cannot get the parameters to work:

Code: Select all

read cw cf cdesc <<< $( identify -format "%w %[fx:h*.04] %[IPTC:2:120]" $1 )
convert $1 \( -clone 0 -size $cs -delete 0 -background black -gravity center -pointsize $cf -fill White caption:$cdesc -trim \) -append $1_annotated.jpg
schievelbein
Posts: 12
Joined: 2013-10-24T11:34:48-07:00
Authentication code: 6789

Re: Annotating photos with metadata

Post by schievelbein »

Thank you again for all of the help from everybody.
Here is the final code with only one little issue.
I wish that I could put a blank line before the text so I could crop the text off later if I wanted.
The way it is now, some of the text overlays the photo.

Code: Select all

read cw cf cdesc <<< $( identify -format "%w %[fx:h*.03] %[IPTC:2:120]" $1 )
convert $1 \( -clone 0 -size $cw -delete 0 -background black -gravity center -pointsize $cf -fill White caption:"$cdesc" -trim \) -append $1_annotated.jpg
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Annotating photos with metadata

Post by fmw42 »

Generally a good idea to put +repage after the trim. Can you post your input and result to some place such as dropbox.com and put the URL here so we can see where the text is getting cropped off and possibly suggest a fix? IM 6.7.7 is very old and perhaps the caption issue has been fixed by now.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Annotating photos with metadata

Post by snibgo »

schievelbein wrote:I wish that I could put a blank line before the text so I could crop the text off later if I wanted.
With current IM, you can put "\n" or "\n\n" at the start of the "caption:" string.
snibgo's IM pages: im.snibgo.com
schievelbein
Posts: 12
Joined: 2013-10-24T11:34:48-07:00
Authentication code: 6789

Re: Annotating photos with metadata

Post by schievelbein »

Thank you again for all of the help and suggestions.
I am using version 7.0.5-4 but still could not get the \n to work, maybe I was putting it in the wrong place?
Here is my code as it stands and all is good except that the caption overwrites part of the photo.
If I could figure out how to insert a line in the caption so that there is a space in case I need to crop the annotated image and re-annotate it, it would be great. I run this code by typing "annotate Test.jpg".
Any and all suggestions are helpful.

Code: Select all

read cw cf cdesc <<< $( identify -format "%w %[fx:h*.03] %[IPTC:2:120]" $1 )
convert $1 \( -clone 0 -size $cw -delete 0 -background black -gravity center -pointsize $cf -fill White caption:"\n $cdesc" -trim \) -append $1_annotated.jpg
Test.jpg
Image

Test_annotated.jpg
Image
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Annotating photos with metadata

Post by snibgo »

schievelbein wrote:caption:"\n $cdesc" -trim
Well, you are adding blank space then trimming it off. If you need the "-trim", then you can add black space afterwards.

Or you could have a third image between your $1 image and the text. This image could be "-size 1x10 xc:White".
snibgo's IM pages: im.snibgo.com
schievelbein
Posts: 12
Joined: 2013-10-24T11:34:48-07:00
Authentication code: 6789

Re: Annotating photos with metadata

Post by schievelbein »

THANK YOU very much, such a simple solution that I overlooked.
My script is working great and I am adding it to my workflow.
THANK YOU for all of the help.
Post Reply