Converting a Transparent Background EPS to PNG

I’m going to blog this so that I don’t have to work it out from first principles again every single time I want to convert an EPS file with a transparent background into a PNG whilst preserving that transparency (you can export EPS files to PNG on a Mac simply using Preview, but annoyingly it always gives them a white background).

You’ll need to install ImageMagick (which you can do simply and easily on Mac OS X using Homebrew). Then simply run a command like this on the terminal:

convert -density 400 -colorspace rgb TransaprentBackgroundEPS.eps -transparent white Output.png

The important bit here is that the “-transparent white” bit comes AFTER the name of your EPS file, not before.

The only case where this doesn’t work (which may well be a very important case, depending on the image) is if the image itself has white in it. In those cases the white bits will disappear – as was the case for me with the PrayerMate logo I was trying to convert.

Edit: if you’re having colour issues when going from EPS to PNG, try using “-colorspace srgb” instead