Page 1 of 1

Resize and text watermark - comments please

Posted: 2011-07-23T14:41:52-07:00
by jessejazza
[using Linux Xubuntu].

I've just started using IM. Previously used Picasa to resize and watermark images... big mistake as IM is that much faster and a natural choice for me as i use llgal for albums. I've found there's quite a bit of reading necessary and i'm unsure of a few things which i'd be grateful for comments/feedback on. I bought the book "Imagemagick Tricks" by Salehi which seems to have some mistakes. I've read most of the website http://www.imagemagick.org/Usage/ but i'm still unsure on certain things.

For pics i use the date for a directory [original size 1600x1200] and then copy images to a directory below for resizing and watermarking. The linux "open terminal here" on a directory is just ideal for IM. I want to do resize and watermark on one commandline and make an alias for the bashrc. Mogrify is fine but i'm not sure of the following.

a] resize
mogrify -resize 50% *.jpg

The command as above worked fine. But the book said that one can do -resize 800x [for an 800 x 600 reduction] or -resize 800x600] didn't work?

b] watermarking
mogrify -pointsize 20 -draw "gravity southeast fill black text 0,12 'jessejazza' fill white text 1,11 'jessejazza'" *.jpg

mogrify -pointsize 20 -gravity southeast -draw "fill black text 0,12 'jessejazza' fill white text 1,11 'jessejazza'" *.jpg

i] fonts. I should be able to specify a font but i've got confused with what i've read. Linux is different to windows... ok i've sized a font but it wasn't Arial or any chosen.

ii] i understood the positioning but one can also use annotate. Ideally i'd like to position the watermark in the same place as Picasa put it. -gravity southeast puts it too close to the right side of the pic. I've tried to copy what picasa did as default. e.g.
http://jessejazza.110mb.com/photos/dogs ... index.html

iii] the options are normally separated by a '-' in llgal and so it appears the same principle is applied to IM. I copied and pasted from examples but i'm unsure why -draw "gravity southeast fill..."etc should work with gravity in "" and the other example -gravity southeast -draw "fill..."etc follows what i would expect.

Perhaps i've got the wrong approach and some kind soul could comment and advise. Thanks

Re: Resize and text watermark - comments please

Posted: 2011-07-23T16:23:19-07:00
by fmw42
Not quite sure of all your commands or what is or is not working for you. Perhaps you should post your exact commands and tell us if it is or is not working and how. Nevertheless all the books are very old and IM syntax and functions have progressed dramatically since then. The Examples pages (Usage) is your best bet.

With mogrify, I would suggest that you use -path to specify placing your results in a different directory so that you don't accidentally overwrite the file with a mistake.

A) There should be no problem with resizing any image unless you have too little memory.

C) You should specify a font as -font fullpathto/font.ttf (ttf fonts are best -- not all fonts work).

B) Use -annotate as you can then specify an offset from the -gravity setting (and have more flexibility with respect to undercolor and slanting).


Try this (have your files in folder1 -- use whatever folder you have -- create a new folder2 to hold your results -- call it whatever you want)

mkdir folder2
cd folder1
mogrify -path /fullpathto/folder2 -format jpg \
-resize 50% \
-pointsize 12 -gravity southeast -font /fullpathto/arial.ttf \
-fill black -annotate +10+10 'jessejazza' \
-fill white -annotate +11+11 'jessejazza' \
*.jpg

[solved] Re: Resize and text watermark - comments please

Posted: 2011-07-24T14:42:27-07:00
by jessejazza
Thanks for the reply.

Under b] watermarking both lines work but i don't understand the syntax as one is putting -gravity in brackets.

But anyway your recommendation has worked perfectly.

The following is what i've decided on after more experimenting.

mogrify -font /home/james/.fonts/FreeSerifItalic.ttf \
-pointsize 22 -gravity southeast \
-fill black -annotate +10+10 'jessejazza' \
-fill white -annotate +11+11 'jessejazza' \
*.jpg

I don't follow the font selection though. In linux fonts are in different forms to m$windows.

I went to /usr/share/fonts/truetype/freefont and chose one from there. Well... a double click on the .ttf and a popup with install which i clicked. One then ends with a font in the home directory .fonts which i set a path to (i'm not sure if that's what you meant... it didn't like a path to /usr/share/fonts/freefont/FreeSerifItalic.ttf).

[solved]
So i'm very grateful although i would like to learn from the experience with the fonts.

Re: Resize and text watermark - comments please

Posted: 2011-07-24T16:23:48-07:00
by fmw42
The issue between -draw and -annotate is that -draw does not support the use of -geometry (as far as I could tell), But -annotate has that offset built in.

If you are on Unix, you can run Anthony's imagick_type_gen.pl script. It modifies the type.xml file. Then you can use just the name of the font, such as, arial, without the .ttf and the full path. But be sure to follow all directions in the script for placing the type.xml in the right place.

See
http://www.imagemagick.org/Usage/scripts/
http://www.imagemagick.org/download/www/resources.html -- see type.xml

Anthony is best to ask about font questions.

Re: Resize and text watermark - comments please

Posted: 2011-07-25T16:50:37-07:00
by anthony
fmw42 wrote:The issue between -draw and -annotate is that -draw does not support the use of -geometry (as far as I could tell), But -annotate has that offset built in.
There are quite a number of differences between the two methods. But both eventually use the low level MagickCore draw command, (after handling any escapes).

both can position text!

-annotate was created to make 'drawing text' easier, removing the need to add quotes (for IM) inside the draw (MVG string) argument quotes (for the shell). That is -annotate only needs the quotes for shell handling of its argument, and for a single word argument does not even need those quotes.

EG: -draw "text 20,30 'word'" vs -annotate +20+30 word

annotate also provides correct and simple handling of text rotations at the position indicated, where draw requires a fair amount of special handling to 'warp the drawing coordinates' do do that rotation. For example on how this is done (developed before -annotate was added in early IMv6 development) see http://www.imagemagick.org/Usage/annota ... t_rotation This complexity was actually one of the reasons IM examples was originally created as it required a lot of experimentation to get the MVG drawing primitive order correct.

The only other differences is that annotate allows percent escapes, where draw text does not. Percent escapes was removed from draw MVG as it caused many problems with internal MSVG rendering of SVG vector images. backslash escapes such as for quotes, \n for linefeed, and \\ for backslash itself, is still understood by BOTH.

BOTH text drawing techniques allow reading of the string to draw from a file (@ prefix), and both assume that the file has been fully formatted and as such does not do require either percent escapes or backslash handling. The text read from the file is passed to "freetype" as is without change.