Adding apache icons for bzip2 and xzip files like gzip
Overview
I wanted to set up Apache httpd to show directory listings and have specific icons for the different archive file formats. In my apache 2.4.6 on CentOS 7, I already see a compressed.png which is displayed for gzip tarballs. I started investigating using fully custom icons, before I realized I should just use different colors of the extant compressed.png file!
$ ls -al /usr/share/httpd/icons/compressed*
-rw-r--r--. 1 root root 1038 Nov 20 2004 /usr/share/httpd/icons/compressed.gif
-rw-r--r--. 1 root root 1108 Aug 28 2007 /usr/share/httpd/icons/compressed.png
So I decided to colorize the existing one. After some fiddling with ImageMagick, I came up with these statements. Because why do things manually when you can do them programatically even if it takes 6 times longer to learn and do it? Actually, the reason is I wanted to swap colors while keeping the transparency.
$ convert compressed.png -alpha set -channel RGBA -fuzz 20% -fill '#55DD55' -opaque red compressed-green.png
$ convert compressed.gif -alpha set -channel RGBA -fuzz 20% -fill '#55DD55' -opaque red compressed-green.gif
$ convert compressed.png -alpha set -channel RGBA -fuzz 20% -fill blue -opaque red compressed-blue.png
$ convert compressed.gif -alpha set -channel RGBA -fuzz 20% -fill blue -opaque red compressed-blue.gif
Great! So now I have the files in /usr/share/httpd/icons. So now to tell httpd to use them for bzip2 and xz (arbitrary colors), add them to apache somewhere. I added them to my virtual host definition.
AddIcon /icons/compressed-green.png .tar.bz2
AddIcon /icons/compressed-blue.png .tar.xz
And one service httpd reload
later, my icons work!
References
http://www.imagemagick.org/Usage/color_basics/
Comments