Page 1 of 1

Embed text in an old IM version

Posted: 2012-06-22T15:10:54-07:00
by marciano
Hello, I´ve been trying some commands but they seem only to work on new versions
Mine is 6.2.8 (up-to-date from Centos repositories, I don't want to upgrade for security reasons)
I just want to embed a text in the middle of a bunch of jpegs into a directory. Text length should be 400 pixels or something less.
Thanks for your help

Re: Embed text in an old IM version

Posted: 2012-06-22T17:10:38-07:00
by fmw42
what commands did you try?

see
http://www.imagemagick.org/Usage/text/

Re: Embed text in an old IM version

Posted: 2012-06-23T09:09:00-07:00
by marciano
Hi,
I found a composite way using a png stamp 'composite -gravity Center wm.png source target' but I cannot use it in mogrify applied to a dir content.
Thank you

Re: Embed text in an old IM version

Posted: 2012-06-23T10:00:08-07:00
by fmw42
mogrify only works with one image at a time. No second image is allowed (except is special cases as noted in the second link below). So you have to write a script to loop over your images and process them as desired.

see
http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics ... fy_compose
http://www.imagemagick.org/Usage/basics/#mogrify_not

Re: Embed text in an old IM version

Posted: 2012-06-23T10:41:31-07:00
by marciano
Okay, thank you Fred, I got it. Thank you

#!/bin/sh
for f in *.jpg
do {
composite -gravity Center wm.png $f $f
}
done

Re: Embed text in an old IM version

Posted: 2012-06-23T13:09:29-07:00
by fmw42
I think you could have used -draw to composite your image over the other and still use mogrify as described in http://www.imagemagick.org/Usage/basics ... fy_compose

Re: Embed text in an old IM version

Posted: 2012-06-25T19:30:19-07:00
by anthony
fmw42 wrote:mogrify only works with one image at a time. No second image is allowed (except is special cases as noted in the second link below). So you have to write a script to loop over your images and process them as desired.

see
http://www.imagemagick.org/Usage/basics/#mogrify
http://www.imagemagick.org/Usage/basics ... fy_compose
http://www.imagemagick.org/Usage/basics/#mogrify_not
Though that will change in IMv7 (at some point in the development).
But in the mean time try the above links for alternative methods.

Re: Embed text in an old IM version

Posted: 2012-06-28T09:28:27-07:00
by marciano
Thanks for your help.
In my old version 'draw' does not work.

I have another question

Code: Select all

convert  source.jpg -resize 500x500 -composite -gravity Center stamp.png target.jpg
This is a simplified line from real one. The problem I have is that '-gravity Center' does not work. stamp.png is placed up and left (north-west) corner.
Thank you

Re: Embed text in an old IM version

Posted: 2012-06-28T09:56:10-07:00
by fmw42
try

convert \( source.jpg -resize 500x500 \) -gravity Center stamp.png -composite target.jpg

-composite has to be at the end and -gravity center before the second image. If on windows use (...) rather than \(...\) or try without parens, though to be sure that resize does not affect the second image, I always add the parens.

see

http://www.imagemagick.org/Usage/compose/#compose
http://www.imagemagick.org/Usage/basics/#parenthesis
http://www.imagemagick.org/Usage/layers/#convert

Re: Embed text in an old IM version

Posted: 2012-06-28T10:22:12-07:00
by marciano
It still displays stamp.png at top-left with or w/o parenthesis
Thank you

PS: sorry, I found the error. Your suggestion is good. Thank you. (in some of my tests I accidentally replaced stamp.png by source.png, that with stamp at up-left side)

Re: Embed text in an old IM version

Posted: 2012-06-28T10:43:30-07:00
by fmw42
marciano wrote:It still displays stamp.png at top-left with or w/o parenthesis
Thank you

What OS are you on? And more importantly, what version of IM?

Can you provide links to your two images. I am having a hard time believing that it does not work.

Re: Embed text in an old IM version

Posted: 2012-06-28T11:43:44-07:00
by marciano
Fred, I edited my previous post.
I didn't realize that in one of my old tries of convert, stamp.png was substituted by that bad target.jpg and of course, any new attempt composing the bad stamp.png would result in the same not desired image.
Fixing that your suggestion was good.
I appreciate and sorry you took hard time to see what could be happend with that command line.
Thanks again

Re: Embed text in an old IM version

Posted: 2012-06-28T13:18:39-07:00
by fmw42
marciano wrote:Fred, I edited my previous post.
I didn't realize that in one of my old tries of convert, stamp.png was substituted by that bad target.jpg and of course, any new attempt composing the bad stamp.png would result in the same not desired image.
Fixing that your suggestion was good.
I appreciate and sorry you took hard time to see what could be happend with that command line.
Thanks again
No problem. Glad you fixed it. I see the edit now.

Re: Embed text in an old IM version

Posted: 2012-07-02T07:43:54-07:00
by marciano
This draws a black rectangle and a text on it.

Code: Select all

convert -size 440x290 xc:lightblue \
          -draw "fill black rectangle 420,0 440,150 \
                 font AvantGarde-Demi  font-size 14   \
                 fill white  \
                 translate 435,100 rotate -90 text 0,0 \' Anthony \'" \
          draw_mvg.gif'
As I wrote before I cannot use some new techniques described in IM manual to get this:
White text over rectangle black opacity 0.5 over a 440x290 image instead of c:lightblue

About opacity I've tried to emulate this code (it works) adding -opacity 0.5 to the previous command but no text is printed.

Code: Select all

convert -size 200x200 xc:skyblue -fill white -stroke black \
          -draw "fill -opacity 0.5 rectangle 50,200 50,0 " \
          set_fill_opacity.gif
Thank you

Re: Embed text in an old IM version

Posted: 2012-07-02T10:16:54-07:00
by marciano
I found a way. It is highly probably it could be cleaned

Code: Select all

convert -size 440x290 xc:transparent \
          -draw "fill black fill-opacity 0.2 rectangle 420,0 440,150 \
                 font AvantGarde-Demi  font-size 14   \
                 fill white  \
                 translate 435,100 rotate -90 text 0,0 \' Anthony \'" \
          draw_mvg.gif'
composite -gravity Center draw_mvg.png source.jpg  target.jpg