Looking for % property variables meanings

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
frrobert
Posts: 2
Joined: 2011-01-03T08:26:52-07:00
Authentication code: 8675308

Looking for % property variables meanings

Post 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
Bonzo
Posts: 2971
Joined: 2006-05-20T08:08:19-07:00
Location: Cambridge, England

Re: Looking for % property variables meanings

Post 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 ?
frrobert
Posts: 2
Joined: 2011-01-03T08:26:52-07:00
Authentication code: 8675308

Re: Looking for % property variables meanings

Post 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
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Looking for % property variables meanings

Post 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
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply