Page 1 of 1

Labeling Over an image without knowing it dimensions

Posted: 2009-10-21T08:27:45-07:00
by dedis
Hi there,

I need to put a black rectangle of 10pixel of height and 500px of width over the bottom of images of variable height...

I want in fact to label some images less or more like in this tuto:

http://www.imagemagick.org/Usage/annotating/

Code: Select all

convert dragon.gif \
          -fill '#0008' -draw 'rectangle 5,128,114,145' \
          -fill white   -annotate +10+141 'Faerie Dragon' \
          anno_dim_draw.jpg
any help ?

thx :)

Re: Labeling Over an image without knowing it dimensions

Posted: 2009-10-21T09:59:07-07:00
by fmw42
annotate is -gravity sensitive, so you can add -gravity south to position text relative to the bottom of the image. see http://www.imagemagick.org/Usage/text/#annotate and http://www.imagemagick.org/script/comma ... hp#gravity

however, I do not think that -draw is -gravity sensitive. so you will need to build a black image of the size desired and composite it over your image before annotating. -compose ... -composite is -gravity sensitive so you can position the black image over your image relative to the bottom of your image. see http://www.imagemagick.org/Usage/layers/#convert

Re: Labeling Over an image without knowing it dimensions

Posted: 2009-10-21T11:08:26-07:00
by dedis
ok, thanks a lot for answering so quickly. Let's read !

Re: Labeling Over an image without knowing it dimensions

Posted: 2009-10-21T11:58:14-07:00
by dedis
Well, I am really learning a lot with the layering lesson.
I get it in two step :

Code: Select all

$convert -resize 500 image.jpg image-500.jpg
$composite label-rectangle.jpg -gravity south image-500.jpg image-500-labeled.jpg
Do you think there is a more elegant way to do it, in a single line ?

Re: Labeling Over an image without knowing it dimensions

Posted: 2009-10-21T12:35:33-07:00
by fmw42
dedis wrote:Well, I am really learning a lot with the layering lesson.
I get it in two step :

Code: Select all

$convert -resize 500 image.jpg image-500.jpg
$composite label-rectangle.jpg -gravity south image-500.jpg image-500-labeled.jpg
Do you think there is a more elegant way to do it, in a single line ?

Use convert in stead of composite. But I am not sure what each of your images are. So try this

convert \( image.jpg -resize 500 \) label-rectangle.jpg -gravity south -composite image-500-labeled.jpg

see http://www.imagemagick.org/Usage/basics/#parenthesis
and IM 6 syntax at http://www.imagemagick.org/Usage/basics/#cmdline