Mogrify – more pleasant than it sounds

If you are lucky or smart enough to use Ubuntu, then you have a wealth of tools sitting just under your keyboard that you might know owt about.

Two of those are the convert and mogrify tools, which come from the Imagemagick stable. I use these quite frequently for batch conversion jobs.

Here is an example of what these tools can do, specifically mogrify which acts on batches of files.

I have a folder load of transparent images that the client wants on a white background, so I open the command line, navigate to that folder (or just open the command line in that folder directly using Nemo instead of Nautilus) and type the following incantation:

mogrify -format jpg -quality 100 -fill white -opaque none *.png

If we break this down into individual components, then

mogrify this is the command itself

-format jpg The output format, in this case jpg

-quality 100 for jpgs specifies the compression or quality levels. 100 is tops, 1 is rubbish.

-fill white the colour of the fill which will be determined by the next command.

-opaque none deals with the alpha (transparency) channel, by filling it with a colour, which has handily just been specified.

*.png simply tells mogrify to grab any file that ends in “.png”