Convert Between File Types Without an App, Part II

| How-To

Sometimes, we find ourselves having to convert from one file type to another, and the app we have at hand, by Murphy’s Law, doesn’t have the particular conversion we want. Then, searching for a free, reliable app and learning how to do the conversion is a tedious process. In Part I, we discussed text files. Here’s how convert some common graphics file types without all that fuss.

Graphics Files

Just as in Part I of this pair,  all you need to do is open the Terminal app, found in /Applications/Utilities, and use a simple but handy command. The command is “sips” (scriptable image processing system), and it will convert back and forth between these file types:

jpeg, tiff, png, gif, jp2, pict, bmp, qtif, psd, sqi, tga

The sips command does a lot more than convert between file types. In this how-to, I’ll just discuss file conversions. Here’s a simple version of the command that converts between formats:

sips -s format output_format input_file_name --out output_file_name

where output_format is one the strings in the first box above, input_file_name is the file you want to convert, and output_file_name is the converted file. Unlike the textutil command, you must specify the name of the output file.

Note, the simplest way to do this is navigate to the directory where the input file is. For example, if the input file is on your desktop, you have to navigate there with:

cd ./Desktop

For example, I have text file named moon.jpg that I want to convert to moon.tiff. Here’s the command:

Terminal shot

 

The sips command echos the input and output file names.

There are many other options associated with this command. It can flip an image or just rotate it by x degrees, crop to a specified size, and a lot more. I’ll let you explore those on your own. You can do that on the command line with:

man sips
Just hit the spacebar to advance and type a “q” to escape. The options here are extensive, so that’s why I stuck to format conversion.

 

Discussion

There are an enormous number of different graphics file types. OS X’s Preview, for example, will convert between tiff, png, pdf, jpeg, jpeg-2000 and openEXR. That conversion to or from PDF is not found in sips, so the Preview app offers a real advantage there.

Also, an inexpensive, high quality and easy to use app like GraphicConverter will convert between a boatload of graphics file types. But for the sake of completeness, or if you want to write, say, a script to use sips for batch processing, it’s nice to know that you can do the conversion, just like textutil, on the command line for some of the common types.

Finally, for users of legacy files, I am still investigating whether this command preserves the legacy Resource Fork. It’s something for users of very old files to be aware of, but not a concern for the rest of us.

 


 

 

No Comments

Log-in to comment