Page 1 of 1

Looking for % property variables meanings

Posted: 2011-01-03T08:49:57-07:00
by frrobert
I am starting to learn more about ImageMagik and I am trying to figure out some things. One of those things is the meanings of properties variables such as %d or %wx%h.

I have googled and googled and can not seem to find a resource that list the meanings.

In particular I am looking for a variable that pulls the file name.

I am working on convert command that resamples an image, changes the quality and gives the file a new name. But I am not sure what variable to use

convert -resample 72 -quality 80% US*.jpg -set orig:%notsurrewhatgoeshere [filename:orig]Sm.jpg

Thanks in advance

Re: Looking for % property variables meanings

Posted: 2011-01-03T08:55:20-07:00
by Bonzo
See the Imagemagick options page here:
http://www.imagemagick.org/script/comma ... ptions.php

See the examples section here:
http://www.imagemagick.org/Usage

Your code is wrong as the image is read in first - how are you using your code: Linux, php, batch etc.

Code: Select all

convert US*.jpg  -resample 72 -set orig:%notsurrewhatgoeshere [filename:orig] -quality 80 Sm.jpg
Are you trying to read a directory of images and process them all ?

Re: Looking for % property variables meanings

Posted: 2011-01-03T09:57:51-07:00
by frrobert
Thanks for your help

I am using Linux and doing batch processing.

I found the page I was looking for

http://www.imagemagick.org/script/escape.php

and I believe I have my syntax correct

convert *.jpg -resample 72 -quality 80% -set filename:orig %t %[filename:orig]Sm.jpg

Re: Looking for % property variables meanings

Posted: 2011-01-03T18:34:48-07:00
by anthony
That is quite good. But I would warn you that it will read ALL you images into memory first at there full size.
More than likely you will end up with a very slow processing as IM switched to using disk space when memory limits are reached.

One way of reducing memory needs is to use read modifiers to "resize on read"
http://www.imagemagick.org/Usage/files/#read_mods
You can combine this with JPEG size hints. But make the jpeg size hint a little larger so it does not reduce your thumbnail quality.
See Thumbnail Handling
http://www.imagemagick.org/Usage/thumbnails/#profiles

And finally process your images one at a time, or in groups, using a 'find | xargs' pipeline.
For example look for jpg files which are not 'Sm' Jpg files.

Code: Select all

   find . -type f -name '*.jpg' \! -name '*Sm.jpg' -print0 | xargs -0 -i convert '{}' ....
that has the added advantage of also allowing recursive searches of a directory tree!
See the man pages for find and xargs.
Also see.. Batch processing alternatives...
http://www.imagemagick.org/Usage/basics/#mogrify_not