It’s frustrating how long it takes me to figure out how to do something in ImageMagick1. I know full well it can do it, but the options are a maze that feels like I’ll have to get a post-graduate degree to understand.
I’m posting this as a public note-to-self as it may make the search easier for someone else.
To do a pretty decent job of converting a PNG-24 with varying transparency to a matted JPEG, you can run this command (substituting another color if you prefer):
convert file.png -background white -mosaic +matte file.jpg
The PNG/JPEG below were converted from the System Preferences 1024px icon on the command line; resized with sips
(a default utility on OS X) and converted to matted JPEG with ImageMagick’s convert
2. Note that the drop shadow survived. Also note the the command isn’t ridiculously long. Much shorter, in fact, than the many I tried before that one.
That is all.
Nope, that’s not all: a note from Aaron McLeod about Ruby library image_sorcery just made my day. Maybe my week.
-
I’d link it for you, but the easiest way to install it is with homebrew (
brew install imagemagick
). ↩ -
And cleverly extracted using the simple command
geticon System\ Preferences
. How, you ask? ↩