Tools of the Trade: ImageMagick

Tools of the Trade

Frequently at Halide Supply we need to do a lot of batch image conversions. For most of these purposes we use the command-line tool called ImageMagick. Sure, most of what ImageMagick can do can be accomplished with Photoshop but often times it isn't the right tool for the job. ImageMagick along with the BASH terminal shell is one of the most essential tools in our workflow. Instead of just writing this guide as an internal procedure I thought some of you guys might find it interesting and helpful in your own workflows.

To install imagemagick on Mac OS X you will need the brew repository which you can get at this link. Once you've got brew, install imagemagick through the following command:

brew install imagemagick

On Windows you can install imagemagick natively though I think using the Windows Subsystem for Linux may be more helpful.

On Debian based Linux systems or the Windows Subsystem for linux use the following command:

 sudo apt-get install imagemagick

Before you begin using Imagemagick some basic understanding of BASH is required. I recommend Corey Schafer's videos on youtube for beginners. You will need to learn how to navigate your folder structures via the terminal and a few basic utilities.

1. BMP to JPG

The Frontier software typically only exports in .JPG or .BMP, an entire order of 36 frame BMP photos can be close to 2GB in size. Ofte a scanner has been left on .BMP with us only realising after we've exported the roll. This requires a need for a tool that can quickly convert these BMP files to JPG or TIFF. For this purpose we use this command.

 mogrify -format jpg *.bmp && rm *.bmp

Let me break that down for you:
mogrify is the batch image conversion command.
-format jpg is our output filetype.
*.bmp 
means all the files with the .bmp extension (keep in mind that unix operating systems are cases sensitive so if your files are .BMP specify *.BMP instead). You can replace this specification for any other filetype you wish to convert. * is a wildcard to match all filenames.
&& bash command for "if the previous command was successful proceed to the next command."
rm *.bmp is a bash command to remove all .bmp files in the directory. be careful with rm though as it permanently deletes files.

2. Greyscale Conversion

A prewar WW2 photo of some Japanese women, Jed found this negative in Japan a few years ago (6x9 120).

As you might have noticed the above photo has a slight sepia tone to it, it's just how the Frontier system works in regards to black and white scans. However I'm not always a fan and neither are some of our customers. I for one typically run the following command to convert my frontier scans to true black and white.

 mogrify -type grayscale *.JPG

Be mindful that mogrify will overwrite your images unless you specify a different filetype through -format, so make sure you backup your files before you try this command.

I used the following command to combine the before and after images

convert +append *.JPG output.jpg


3. Contact Sheet

Admittedly I haven't used this that much but the use case is interesting. It does require some more advanced knowledge with Imagemagick especially in regards to changing your policy.xml file. That file handles how much computing power Imagemagick is able to use. If you try this command before you do so, it may result in a memory shortage error.

montage -geometry 500x -tile 6x6 -density 300 -label "%f" -pointsize 9  *.JPG contacts.jpg

montage is the command for compiling serveral files into one
-geometry affects the total pixels each image will use on the canvas
-tile affects how many images are tiled
-density is the dpi
-label "%f" use the file name as a label
-pointsize font size of the label
*.JPG convert all files matching this
contacts.jpg is the output file

4. Animate

 

Imagemagick can also animate images into .gif or video files based on a series of images. I have this folder with 3d renders of the Halide Supply logo I did in Blender a few months ago. Quickly with Imagemagick I can compile them into .gif file for web use, in fact our logo on the main page was created this way.

convert -delay 1x30 -resize 300x300 -loop 0 -dispose previous *.png animate.gif

convert to create the new file
-delay 1x30 sets the fps to 30 frames per second
-resize 300x300 sets the dimensions of the .gif file
-loop 0, loop forever
-dispose previous removes the previous frame each time a new frame is drawn
*.png affect all png files in my working directory
animate.gif is the output file


Older Post


  • XHKFZtxYyzpB on

    kPziVmdGTlXHw

  • tHIGhYBPcdOzDNg on

    JtWDqfyIaKziHR

  • YsVEXThLbUcJiD on

    VqKxIfcTRoaPkMjC

  • GnUmWiNtqP on

    tgHqyJMup

  • Sasina on

    The magic that makes me go WOW, NICE whenever I see you do it.



Leave a comment