Label pictures

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
sebtux
Posts: 2
Joined: 2015-01-29T11:42:04-07:00
Authentication code: 6789

Label pictures

Post by sebtux »

Hi,

I would like to label lots of photographs for a website as NatGeo does with some of their shots (ie http://2.bp.blogspot.com/-4mxYjp-CyUE/U ... 712187.jpg) Just the text part at the bottom-right, not the logo.

As far as I understood ImageMagick's power, it would be enough to determine the width of the images, create a semi-transparent rectangle and Annotate some text over it with "gm compose..."

My doubts are:
a- Is it possible to create a semi-transparent rectangle that fits exactly the size of the text? Should I create an image with the text first?
b- Is it possible to align it to the bottom-right (southeast) of the image?

TIA. -Seb
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Label pictures

Post by fmw42 »

gm compose...
That is a GraphicsMagick command? This is not GraphicsMagick forum, it is Imagemagick.

Nevertheless, all what you ask is possible. You would create the text on a semi-transparent background using convert ... label:"yourtext" and then composite it over the image using -gravity to set to the desired corner.

Something like (unix syntax)
( for windows remove the \ before the parens)

convert backgroundimage \( -backgroundcolor "rgba(255,0,0,0.5)" -pointsize 18 -font arial label:"yourtext" \) -gravity southeast -compose over -composite resultimage

see
http://www.imagemagick.org/Usage/text/#label
http://www.imagemagick.org/script/color.php
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/layers/#convert
http://www.imagemagick.org/Usage/compose/
http://www.imagemagick.org/script/comma ... hp#gravity

Always a good idea to provide your IM version and platform!
sebtux
Posts: 2
Joined: 2015-01-29T11:42:04-07:00
Authentication code: 6789

Re: Label pictures

Post by sebtux »

Thanks a lot, yes, I'm using Linux, a little overhelmed and confused for the tons of options and by mistake have replaced imagemagick with graphicsmagick... that didn't helped I suppose. Now have installed ImageMagick 6.6.7. Thanks again.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Label pictures

Post by fmw42 »

IM 6.6.7 is quite old (over 200 versions). You would be best to upgrade if you can.
Post Reply