Creating Windows icons

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Creating Windows icons

Post by SharkD »

Hi!

I'm trying to create some layered images in a format that supports layers and is readable by the GIMP. I've tried PSD, MNG and TIFF, but the PSD images comes out all garbled and the MNG and TIFF images are flattened. Writing to XCF (GIMP native format) doesn't seem to be supported by ImageMagick. I would appriate some help.

Thanks!

-Mike
Last edited by SharkD on 2008-09-28T11:36:25-07:00, edited 1 time in total.
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Saving to a format that supports layers

Post by SharkD »

Update: I was able to save as TIFF with multiple frames. The GIMP then asks if I want to convert each frame to a layer when I open the TIFF file.

Still, being able to save directly to an layered image would be a time-saver.
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

When creating Windows icons there is a strange border surrounding the image.

Here is an example of what it looks like:
Image

Here is what it's supposed to look like:
Image

Can someone please describe how to get rid of it?

Here is the command-line I am using:

Code: Select all

convert abomination_256_fate.png abomination_048.png abomination_032.png abomination_016.png abomination_fate.ico
I've also tried using this:

Code: Select all

convert abomination_256_fate.png abomination_048.png abomination_032.png abomination_016.png -alpha on -channel RGBA -depth 8 abomination_fate.ico
I am using ImageMagick version 6.3.7 Q16.

Thanks!

-Mike
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

I updated to the latest version of IM and the problem no longer exists. However, one oddity is that I have to reverse the alpha channel of the input images before converting them to icons.

Here's the command-line I used:

Code: Select all

convert fate_abomination_256.png fate_abomination_048.png fate_abomination_032.png fate_abomination_016.png -channel Alpha -negate fate_abomination.ico
Also, I haven't yet figured out how to compress the Vista icon (256x246px). Compression should bring the file size down to about 25% of normal.
Last edited by SharkD on 2008-09-28T18:57:54-07:00, edited 1 time in total.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating Windows icons

Post by fmw42 »

If you are running Q16 IM, then add -depth 8. That will cut your size in half.

As for GIF compression, see -colors and -quantization

http://www.imagemagick.org/Usage/formats/#gif
http://www.imagemagick.org/Usage/quantize/#colors
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

The icons use the PNG format, not GIF.

I've tried "-compress Zip" and "-compress Lossless", but neither have an effect on the file size. The input file (a compressed PNG file--the second image in the above post) is ~76KB; the output file (an Windows icon) is ~265KB.

Incidentally, using "-compress None" on the source image doesn't remove the compression: the file stays at 76KB.

Here are the command lines I am using:

Code: Select all

convert fate_abomination_over.png -compress Zip fate_abomination_test.ico

Code: Select all

convert fate_abomination_over.png -compress None fate_abomination_test.png
The first is for compressing the icons; the second is for removing compression from the source image.

Also, I wasn't sure which form of compression to use. Wikipedia says PNG uses zlib compression. I took a wild guess and assumed that this is what the "Zip" compression is referring to.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating Windows icons

Post by fmw42 »

See http://www.imagemagick.org/Usage/formats/#png for PNG compression.

Also what about -depth 8 or are you on Q8 IM?

You many need some other png compression tool other than IM. See the apps mentioned in the above link.

Anthony may be able to help more.
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

Another problem related to the reversed alpha issue I mentioned above is that, after inverting the alpha channel, the "thumbnail preview" of the icon shows only the mask (or, rather the image with the inverse of the alpha channel applied to it). Not inverting the alpha channel results in the thumbnail preview rendering properly, but then the icons themselves suffer from this problem.

I believe this is a sign that there is a bug in ImageMagick where masks are being processed instead of alpha channels in some cases, and/or vise versa.

[edit]
Yes, I am using Q8.

After reading the article you linked to I tried the following command-line without success:

Code: Select all

convert fate_abomination_over.png -compress Zip -quality 95 fate_abomination_test.ico
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Creating Windows icons

Post by el_supremo »

According to the wikipedia article on the icon file format, http://en.wikipedia.org/wiki/ICO_(icon_ ... le_format), the 256x256 icon can be "PNG compressed".
However, I've had a brief look through the source code for the icon coder and as far as I can tell it does not do any compression at all.

Pete
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

Note also that the GIMP provides users with several options regarding colordepth and compression for each frame of the file.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Creating Windows icons

Post by fmw42 »

Sorry, I doubt I can help any further at this point.

However, there were quite some changes going on in IM 6.4.4.-7 regarding -alpha. see changelog http://www.imagemagick.org/script/changelog.php and also Controlling Transparency on http://www.imagemagick.org/Usage/basics/

Don't know if that relates to your problem.

If you think there is a problem, then I would suggest you report it on the Bugs forum, if you don't get any where further.

If it is a new compression feature that you need (to match GIMP or just missing), then I recommend you suggest it on the Developers forum.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Creating Windows icons

Post by anthony »

Check with the latest version of Im to see if the transparency channel is being handled correctly for ICO images.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

fmw42 wrote:However, there were quite some changes going on in IM 6.4.4.-7 regarding -alpha. see changelog http://www.imagemagick.org/script/changelog.php and also Controlling Transparency on http://www.imagemagick.org/Usage/basics/
I don't see a change log for 6.4.4.-7.
anthony wrote:Check with the latest version of Im to see if the transparency channel is being handled correctly for ICO images.
I am already using 6.4.4 Q8 which I think is the latest version.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Creating Windows icons

Post by anthony »

He meant 6.4.3-7
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
SharkD
Posts: 35
Joined: 2006-07-30T13:18:31-07:00

Re: Creating Windows icons

Post by SharkD »

The version I have supercedes 6.4.3-7 doesn't it? So, I should go ahead and file a bug report, right?
Post Reply