Apr 08 2004

Converting OSX Icons to png

Published by Adam at 11:02 am under ,, ,

I found some Matrix icons that I wanted to use on my Linux desktop. Unfortunately, the only available formats are for OSX or Windows (.ico). I prefer to use png, so I set out to convert the OSX-flavored icons to png.

You will need to download and install a few programs in order for this to work.

First, you need to get a copy of StuffIt for Linux. For those of you morally opposed to using close-source software, shame on you for even considering using Macintosh icons on your Linux desktop. Begone, you.

Next, download yourself a copy of icns2png [Local mirror].

Finally, grab these two scripts: clean and convert. Don’t forget to mark them executable.

Extracting the .bin/.hqx
I downloaded mtrx_icn.bin and saved it to ~/icons. Unstuff this .bin file to seperate the data in to two files.

stone@durin:~/icons$ unstuff mtxr_icn.bin
The Matrix Rebooted Icons.sit.info
The Matrix Rebooted Icons.sit.data
/home/stone/icons/The Matrix Rebooted Icons.sit.info ..
/home/stone/icons/The Matrix Rebooted Icons.sit.data ...........................................................................................................
stone@durin:~/icons$

Next, we need to extract the actual icons themselves. Without setting the parameters to tell unstuff how to treat the file, it will extract 0-byte Icons.

stone@durin:~/icons$ unstuff -e=unix -m=auto -t=on The\ Matrix\ Rebooted\ Icons.sit.data
...
(lots of files being extracted)
...
stone@durin:~/icons$

Fixing the filename
When unstuff extracts the Icon files, it leaves behind a carriage return (\r) embedded within the filename. Whoops.


stone@durin:~/icons$ ls -b The\ Matrix\ Rebooted\ Icons
Icon\r Read\ Me\ Please The\ Icons

I tried various ways of using find, xargs, and perl to do this but failed. So what we have here is clean. Simply, it will remove any control codes, including carriage returns and line feeds, from a filename. I spent way too much time trying to find a solution to this, so I hope it comes in handy for someone else.


#!/bin/sh

if [ ! -n "$1" ]; then
echo “Usage: clean.sh
exit 0
fi

set -o noglob
find “$1″ -name ‘Icon*’ -print | while read name ; do
newname=”`echo $name | tr -d [:cntrl:]`”
mv “$name” “$newname” # do the move
done

~/icons$ ./clean The\ Matrix\ Rebooted\ Icons
stone@durin:~/icons$

Converting to png

Now that the filenames are fixed, we can get to our ultimate goal, converting the icons to png. For this, I hacked up another script, similar to clean.sh, and called it convert.


if [ ! -n "$1" ]; then
echo “Usage: convert.sh
exit 0
fi

set -o noglob
find “$1″ -type f -name ‘Icon’ -print | while read name ; do
icns2png “$name” # Convert to png
rm “$name” # remove old Icon
done

This one is simple enough that you can probably accomplish the same thing with find, -exec and xargs.

Matrix\ Rebooted\ Icons
Icon2PNG Linux Edition - (C) 2002 Mathew Eis
Converting The Matrix Rebooted Icons/Icon to The Matrix Rebooted Icons/Icon.png...
(repeat the above two lines for each Icon)
stone@durin:~/icons$

And you’re done. All of the OSX Icons have now been converted to png. Happy theming!

18 Responses to “Converting OSX Icons to png”

  1. p33ton 26 Apr 2004 at 11:36 pm

    If you have OSX installed, you can use the trial version of Pixadex to convert them, its really easy as well.

  2. outspokenon 02 Sep 2004 at 5:33 am

    hey, thanks for putting this together, very appreciated. unstuff for linux, who knew.

  3. Christian Brynon 09 Dec 2004 at 6:45 am

    Thanks a bunch!
    And thank you for putting up a local mirror of icns2png, I spent quite some time trying to find somewhere to download it, as the official mirror is down. :-)

  4. kunalon 24 Dec 2005 at 3:39 pm

    hi, m not into programing a all but i hav read lot bout linux n how linux is superior to windows , can u suggest a linux os with easy graphical interface so tht i dont hav to do much of command typing , n i would love to use png format of icons in windows till m not goin for linux….can u help?

  5. amandaon 12 Nov 2006 at 1:56 pm

    I’m looking for icns2png to no avail. I get a file not found error on your mirror. Any leads?

  6. Adamon 12 Nov 2006 at 2:34 pm

    Amanda:

    Sorry about that. I just restored the mirror. Enjoy!

  7. manytigerson 26 Mar 2007 at 9:19 pm

    i get the icon file from the site you given, but it’s a dmg file, how to do now? thx.

  8. manytigerson 26 Mar 2007 at 9:42 pm

    or send it to me: tigerjump98@yahoo.com.cn, thanks.

  9. Alfredon 30 Mar 2007 at 3:39 pm

    One of the best locations I’ve come across lately!!! Definately a permanent bookmark! Please visit my site too:

  10. Katrinaon 30 Mar 2007 at 3:40 pm

    Good site, nice design! Visit my sites, please:

  11. Helenon 30 Mar 2007 at 3:40 pm

    I am very impressed how you can build webpages! Visit my sites, please:

  12. Franklinon 30 Mar 2007 at 6:56 pm

    Thanks bro! Real good work! Please visit my homepage:

  13. Chrison 30 Mar 2007 at 6:56 pm

    Amazing artwork! This is spectacularly done! Please visit my homepage:

  14. Kathyon 30 Mar 2007 at 7:10 pm

    I am very impressed how you can build webpages! Please visit my site too:

  15. Cobleon 30 Mar 2007 at 7:10 pm

    Cool design, great info! Please also visit my site:

  16. Eddieon 30 Mar 2007 at 7:10 pm

    Great looking site so far!! I’m just starting to look around it but I love the title page! Please visit my site too:

  17. Lillianon 30 Mar 2007 at 7:11 pm

    Great looking site so far!! I’m just starting to look around it but I love the title page! Please also visit my site:

  18. Edwinon 30 Mar 2007 at 7:11 pm

    Hi there! Just couldn’t resist your guestbook! Please also visit my site:

Trackback URI | Comments RSS

Leave a Reply