Imagemagick useful cmds: basic bash select, image resize, crop, creation

Imagemagick adapted personal notes.

Most times when I want to do something on several images I use artscript, a small GUI tool to automate most common, and not so common, imagemagick operations. It makes a breeze to prepare a set of images to display on one or several output sizes and formats. artscript backbone is imagemagick command line program, mainly what artscript does is compose the command line option to make imagemagick do its thing.

The remaining times artscript doesn’t fit my imagemagick needs I find it useful to remember the following commands.

General image selection

Use terminal utilities to filter the wanted images and feed the result to either *xargs* or a *for/do loop*. The most common utilities, and easier to remember are: ls and find.


List all files in a directory, using wildcards from bash its possible to filter the results easily.

 $ ls *.png ## list all png
 $ ls draw_*.jpg ## list all jpg starting with 'draw'


For queries more complex or uncertain I use find. find queries can be very complex on its own

$ find . -name '*.ora' ## finds all file and dirs ending with '.ora' (used * wildcard again)
$ find . -type f -name '*.?[pn]?' -ctime -30 ## finds all png and jpg files in current dir created in the last 30 days.

## spaces in characters will break the pipe, use print0 to feed xargs
$ find . -name '*.jpg' -print0

When doing a for loop its not necessary to use xargs, and its possible to feed the bash mini script with patters, this is specially usefull when you know exactly the image you are going to process.

## Inspect all files patterns between 044, 045, 046.. until 050.
## any command can go after the do.
$ for f in 14_{030..050}.ora ; do file $f; done

## Using xargs
$ echo 14_{030..050}.ora | xargs file

Creating Images

Read More »