Labeling Over an image without knowing it dimensions

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
dedis

Labeling Over an image without knowing it dimensions

Post 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 :)
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Labeling Over an image without knowing it dimensions

Post 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
dedis

Re: Labeling Over an image without knowing it dimensions

Post by dedis »

ok, thanks a lot for answering so quickly. Let's read !
dedis

Re: Labeling Over an image without knowing it dimensions

Post 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 ?
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Labeling Over an image without knowing it dimensions

Post 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
Post Reply