Commands
You can use the standard commands/options of ImageMagick's convert utility. The command is followed by the command's parameters. These parameters are enclosed in brackets. Multiple commands are separated by a plus sign.
ImageMagick uses < and > in some parameters. You can't use these in html-documents. Instead of < and >, you may use { and } in your query string. The scripts then converts { to < and } to >.
Here are a few example convert commands and their query equivalent.
| Command line |
Query string |
|
-resize "100x150" |
?resize(100x150) |
|
-resize "800x600>" -roll "90" |
?resize(800x600})+roll(90) |
|
-flip -resize "800x600>" -flop |
?flip+resize(800x600})+flop |
Extra commands
The long list of ImageMagick commands didn't contain some things I wanted to do. I added three 'extra' commands to the script to do this.
part
The first of these commands is part(widthxheight) . With ImageMagick's cropcommand, it is possible to get a part of the image. Unfortunately, this command only accepts absolute parameters. It can crop wby hpixels, starting xpixels from the left and ypixels from the top of the image. But what if I want to get 100x100 pixels from the center of the image? That's impossible if I don't know the size of the image.
Enter the part command. It resizes the image to match either the preferred width or the preferred height. Then it crops the image to get the center part of that resized image. And that's what I wanted to do.
colorizehex
ImageMagick's colorize command accepts only decimal RGB numbers, on a 0 to 100 scale. To colorize with red gives colorize 100/0/0. This isn't ideal for web use, since html uses hex codes to identify colors. The colorizehex(hex) command does accept hex colors. It converts them to the ImageMagick notation. Example: a red colorize is done with colorizehex(FF0000).
type
The type(type) is available in ImageMagick. It's just not a part of the commands, but is appended to the name of the output file (e.g. jpg:output.jpg). I wanted to include it in the query string, so I made it a command. You can now convert the image to jpeg by using type(jpg) in your query.