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?".
I am a genealogist and have thousands of photos that I want to annotate and update at any given time.
I want to maintain the integrity of the original photos, so I am splicing an annotation area to the bottom, so if I need to update the annotation, I can simply trim off the old and add another. The annotations are coming from the metadata that I am maintaining using gThumb in Linux, not that it should matter. The problem is that some of the photos have a LOT of people and the descriptions can be very long. I do not want the font to get too small, so I need word wrap. I thought that CAPTION with its word wrap might be able to help, but I cannot see to get it to work. The second issue that I might have is whether the spliced area will be tall enough. If I could know how many lines I was going to have, I could change my splice to be a multiple of the lines. My first Convert works, but the second does not. Thank you for any suggestions.
magick "input.jpg" ( -clone 0 -fill Black -colorize 100 -gravity north -pointsize 20 -fill White -annotate +0+0 "This is a very very long line and I will repeat some more blurb to make it a bit longer and longer" -trim ) -append "annotated.jpg"
It reads in the original image, copies it and changes it to black. Adds the white text to the now black copy; trims it down to the text size and joins the two images. This process would probably need to add an -extent or similar to get the width back to the size of the original.
magick "input.jpg" ( -clone 0 -size %[fx:w]x%[fx:h] -delete 0 -background black -gravity center -pointsize 20 -fill White caption:"This is a very very long line and I will repeat some more blurb to make it a bit longer and longer" -trim ) -append "annotated.jpg"
Code modified as per fmw42's post below.
Did you try adding +repage after the -trim?
No I didn't fmw42 but just tried and get the same geometry error
Last edited by Bonzo on 2017-04-04T13:43:35-07:00, edited 1 time in total.
convert "input.jpg" ( -clone 0 -size %[fx:w]x%[fx:h] -delete 0 -background black -gravity center -pointsize 20 -fill White caption:"This is a very very long line and I will repeat some more blurb to make it a bit longer and longer" -trim ) -append "annotated.jpg"
I am getting a syntax error and cannot figure it out.
Any recommendation would be greatly appreciated.
Last edited by schievelbein on 2017-04-04T13:43:03-07:00, edited 1 time in total.
My example above worked with caption and text but on testing fails with the %[EXIF:DateTimeOriginal] you may have to go back to reading that data into a variable first.
Did you try my example code with one of your images as it seems to do what you want except for the EXIF and IPTC data?
I tried with a couple of my images and I receive the following:
./annotate: line 8: syntax error near unexpected token `('
./annotate: line 8: `convert "input.jpg" ( -clone 0 -size %[fx:w]x%[fx:h] -delete 0 -background black -gravity center -pointsize 20 -fill White caption:"This is a very very long line and I will repeat some more blurb to make it a bit longer and longer" -trim ) -append "annotated.jpg"'
Thank you very much for the suggestions. The CAPTION is working as advertised, however, now, I am having trouble with the parameters.
I have tried many variation and cannot get the $cdesc and $cw or any of the other parameters to work. Any suggestion on being able to pass these parameters to Size and Caption would be appreciated.
read cw ch cs cf cd ct cdesc <<< $( identify -format "%w %h %[fx:h*.05] %[fx:h*.04] %[EXIF:DateTimeOriginal] %[IPTC:2:120]" $1 )
convert "input.jpg" \( -clone 0 -size 1200 -delete 0 -background black -gravity center -pointsize 20 -fill White caption:"This is a very very long line and I will repeat some more blurb to make it a bit longer and longer This is a very very long line and I will repeat some more blurb to make it a bit longer and longer This is a very very long line and I will repeat some more blurb to make it a bit longer and longer" -trim \) -append "annotated.jpg"