Annotation Woes

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
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Annotation Woes

Post by kiwijunglist »

Annotation woes

This is my script:

Code: Select all

"%~dp0convert.exe" %1 -resize 1778x1778 ^ -gravity center -crop 1000x1000+0+0 +repage ^ "%~dp0fanart.mask.png" -alpha off -compose copy_opacity -composite "%~dp0fanart.overlay.png" -compose over -composite ^ -font candice -pointsize 48 ^ -gravity center -annotate 0 "Hello World" ^ %2
Ideally I want to specify the Y position of the text, but still have the text centered
Also I would like to change the colour of the text to white.

Unfortunately I just can't get it to do that. I'm sure it is possible though.

This is what the output looks like at the moment
Attachments
test.png
test.png (98.12 KiB) Viewed 6699 times
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Annotation Woes

Post by Bonzo »

From memory there is a problem doing the positioning with gravity of the text and then gravity for the location location. I would create the text as a separate image and composite the two.

You should be able to specify the font colour with -fill white
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

Thanks.

Can I do this within the same command line?

(or) will I have to make 3 separate commands?
ie. Make disc image, save to temp image to HDD, Make text image save temp image #2 to HDD, then combine the images?

At the moment I have:

convert.exe %1 -resize 1778x1778 ^ -gravity center -crop 1000x1000+0+0 +repage ^ "%~dp0fanart.mask.png" -alpha off -compose copy_opacity -composite "%~dp0fanart.overlay.png" -compose over -composite ^ temp01.png
convert.exe -background transparent -fill white -font segoe-ui-bold -pointsize 72 -gravity center -size 1000x98 label:"SEASON ONE" ^ temp02.png
convert.exe temp01.png temp02.png -geometry +0+724 -composite %2
Last edited by kiwijunglist on 2013-07-05T17:20:15-07:00, edited 2 times in total.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Annotation Woes

Post by GreenKoopa »

You can easily accomplish this on one command line using convert, no temporary files needed.
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

Hi Koopa, I just edited my post above. Can I just append the lines. I'm not actually a programmer so I do struggle with the ordering.
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

Hi

Thanks for your tips :)

I havn't been able to combine line 2+3 because when i do the resulting image is 1000x98 pixels.

I have been unable to alter line #2 to create a 1000x1000 transparent background where the text is centered on the X axis, but the Y axis is set with a number.
convert.exe -background transparent -fill blue -font segoe-ui-bold -pointsize 72 -gravity north 0+700 -size 1000x1000 label:"SEASON ONE" test.png
I also tried using repage, but that didn't work out very well for me as well.

This is what I have (that is working) so far...

sample.zip http://www.sendspace.com/file/roxqoh

Zip file contains:
run.cmd
fanart.jpg
fanart.sXX.png
fanart.mask.png

Run.cmd (Windows batch file):

Code: Select all

convert.exe fanart.jpg -resize 1778x1778 ^ -gravity center -crop 1000x1000+0+0 +repage ^ fanart.mask.png -alpha off -compose copy_opacity -composite fanart.overlay.png -compose over -composite ^ temp01.png
convert.exe -background transparent -fill white -font segoe-ui-bold -pointsize 72 -gravity center -size 1000x98 label:"SEASON ONE" ^ temp02.png
convert.exe temp01.png temp02.png -geometry +0+724 -composite result.png
It works, but I'm hoping someone can help me combine into a single command.

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

Re: Annotation Woes

Post by snibgo »

Code: Select all

convert.exe ^
  fanart.jpg -resize 1778x1778 ^
  -gravity center -crop 1000x1000+0+0 +repage ^
  fanart.mask.png -alpha off -compose copy_opacity -composite ^
  fanart.sXX.png -compose over -composite ^
  -background transparent -fill white ^
  -font segoe-ui-bold -pointsize 72 -gravity center -size 1000x98 ^
  label:"SEASON ONE" ^
  -geometry +0+724 ^
  -gravity north ^
  -composite ^
  result2.png
snibgo's IM pages: im.snibgo.com
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

BRILLIANT!!! Thank you.
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

I have another question:

I am adding video + audio codecs and studio logos to the disc images I am auto creating. I want the images on the edge of the disc i am creating.
However the logos that I am adding have unknown widths and the X+Y positioning for composition only uses the top left corner of the logos for positioning, so I can end up with images overlaping the right hand edges of the disc.

What I would like to do is either:
1. resize logo image to 250x100, keeping original aspect ratio, with right alignment and fill = transparent
I want to do this to the logo prior to composing it on top of the disc image.
This will allow me to position the items correctly, because I can position them 250px away from the edge and they will always be right on the edge of the disc

2. position the logos, but relative to the logo width eg.
"audio1.png" -geometry +(250+logowidth)+200 -composite ^

Here is sample code:

Code: Select all

  convert.exe ^
  "fanart.jpg" -resize 1778x1778 ^
  -gravity center -crop 1000x1000+0+0 +repage ^
  "fanart.mask.png" -alpha off -compose copy_opacity -composite ^
  "fanart.movie.png" -compose over -composite ^
  -background transparent -fill white ^
  -font segoe-ui-bold -gravity center -size 780x88 ^
  label:"30 Minutes or Less" ^
  -geometry +0+729 ^
  -gravity north ^
  -composite ^
  -gravity center ^
  "audio1.png" -geometry +350+200 -composite ^
  "audio2.png" -geometry +400+120 -composite ^
  result.png
Here is a .zip file containing sample code.bat file + sample images:
http://www.sendspace.com/file/wins2c

If it is not posible I will just have to place images on the left side only...

Thanks
Last edited by kiwijunglist on 2013-07-09T08:09:05-07:00, edited 1 time in total.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Annotation Woes

Post by GreenKoopa »

A -resize, or any operation, applies to each and every image in the current list. Try ( )
http://www.imagemagick.org/Usage/basics/#image_list
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

thank you i will try that.
User avatar
GreenKoopa
Posts: 457
Joined: 2010-11-04T17:24:08-07:00
Authentication code: 8675308

Re: Annotation Woes

Post by GreenKoopa »

Oops, there is a bad link in the documentation (in the table of contents). Try
http://www.imagemagick.org/Usage/basics/#image_lists
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

Thank you, that is working I had originally tried brackets but hadn't put spaces on each side of the bracket, and I didn't persist because I didn't know that was possible.
kiwijunglist
Posts: 14
Joined: 2012-10-15T20:41:33-07:00
Authentication code: 67789

Re: Annotation Woes

Post by kiwijunglist »

convert.exe ^
"fanart.jpg" -resize 1778x1778 ^
-gravity center -crop 1000x1000+0+0 +repage ^
"fanart.mask.png" -alpha off -compose copy_opacity -composite ^
"fanart.movie.png" -compose over -composite ^
-background transparent -fill white ^
-font segoe-ui-bold -gravity center -size 780x88 ^
label:"30 Minutes or Less" ^
-geometry +0+729 ^
-gravity north ^
-composite ^
-gravity northwest ^
( fanart.mask.png -alpha transparent -resize 250x100! ( audio1.png -resize x100 ) -gravity east -composite ) ^ -gravity east -geometry +350+200 -composite ^
( fanart.mask.png -alpha transparent -resize 250x100! ( audio2.png -resize x100 ) -gravity east -composite ) ^ -gravity east -geometry +350+200 -composite ^
result.png

^ thanks it's now working with above code, cheers.
Post Reply