convert not obeying -compress None option?

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?".
Post Reply
kdvolder
Posts: 5
Joined: 2014-01-27T14:32:19-07:00
Authentication code: 6789

convert not obeying -compress None option?

Post by kdvolder »

I'm trying to create a .ico file for a Eclipse icon for windows users.

This is the shell code I'm using:

Code: Select all

$ convert sts512.png -border 0 -compress None \
    \( -clone 0 -resize 16x16 -colors 256 -depth 8 \) \
    \( -clone 0 -resize 24x24 -colors 256 -depth 8 \) \
    \( -clone 0 -resize 32x32 -colors 256 -depth 8 \) \
    \( -clone 0 -resize 48x48 -colors 256 -depth 8 \) \
    \( -clone 0 -resize 16x16 -depth 24 \) \
    \( -clone 0 -resize 32x32 -depth 24 \) \
    \( -clone 0 -resize 48x48 -depth 24 \) \
    \( -clone 0 -resize 256x256 -depth 24 \) \
    -delete 0 -alpha off +compress sts.ico
This seems to work mostly the way I want / expect... except for the fact that the 256x256 image is always stored in
compressed form and 16bit depth.

Code: Select all

$ identify -format '%f %p/%n %m %C/%Q %r %G %A %z\n' sts.ico
sts.ico 0/8 ICO Undefined/0 DirectClassRGBMatte 16x16 True 8
sts.ico 1/8 ICO Undefined/0 DirectClassRGBMatte 24x24 True 8
sts.ico 2/8 ICO Undefined/0 DirectClassRGBMatte 32x32 True 8
sts.ico 3/8 ICO Undefined/0 DirectClassRGBMatte 48x48 True 8
sts.ico 4/8 ICO Undefined/0 DirectClassRGBMatte 16x16 True 32
sts.ico 5/8 ICO Undefined/0 DirectClassRGBMatte 32x32 True 32
sts.ico 6/8 ICO Undefined/0 DirectClassRGBMatte 48x48 True 32
sts.ico 7/8 ICO Zip/0 DirectClassRGB 256x256 False 16
Eclipse wants the final icon (7/8) to be uncompressed and 32 bit.
I'm not really sure why this doesn't work. It does the correct
thing for 16x16, 32x32, 48x48 icons. It even does the right thing
if I change 256x256 into 128x128.

I tried sticking the "-compress None option" explicitly into the 256x256 line
as well, at the beginning, the end etc. Also at the end of the
command. But no matter what I seem to
do it always ends up with the 256x256 image zip-compressed and 16bits.

Any idea what I may be doing wrong here?

Kris

PS: I didn't come up with these commands on my own but found them
here: https://github.com/neo4j-contrib/neoclipse/pull/56

PS2: Imagemagick version info:

Code: Select all

convert -version
Version: ImageMagick 6.6.9-7 2012-08-17 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert not obeying -compress None option?

Post by fmw42 »

There is no depth 24. As I recall, ico are like gifs, they are only 8-bit color, with palette. They do not allow 24-bit total RGB color. Using -depth 24 would mean 24-bits per channel, which is not possible. Someone can correct me on this as I am not positive about ico limitations. I do not think they allow -type truecolor.

try

convert sts512.png -alpha off \
\( -clone 0 -resize 16x16 -colors 256 -type palette -compress none \) \
\( -clone 0 -resize 24x24 -colors 256 -type palette -compress none \) \
\( -clone 0 -resize 32x32 -colors 256 -type palette -compress none \) \
\( -clone 0 -resize 48x48 -colors 256 -type palette -compress none \) \
-delete 0 sts.ico
kdvolder
Posts: 5
Joined: 2014-01-27T14:32:19-07:00
Authentication code: 6789

Re: convert not obeying -compress None option?

Post by kdvolder »

Thanks... the command you suggest works but only gives half of the icons needed (only '8bit' version
of each image).

For whatever reason, the .ico file for Eclipse launcher needs two versions of each icon 16x16 - 48x48
one version needs to be 8bit and the other 32 bit. For the 256x256 it needs only 32 bit.

I found this info here:
http://andrius.velykis.lt/2012/10/creat ... -launcher/

It looks like the command I copy pasted is a bit of nonsense. (I think I get your explanation why the 24 makes no sense).

Wikipedia does show there's a bit in the .ico file format to indicate use palette or not.

And the link above states this:
The ICO file supports all resolutions outlined in the .product file, in 32-bit (RGB / Alpha Channel) and 8-bit (256 colors, indexed) BMP icons:
This is better information than I'd been able to find before. But I'm still having a bit of trouble figuring out how to translate that into
a 'convert' command. I think I need your command to create the 8 bit indexed images... and then some extra stuff at the end to also create the
32-bit RGB+alpha channel images as well.
kdvolder
Posts: 5
Joined: 2014-01-27T14:32:19-07:00
Authentication code: 6789

Re: convert not obeying -compress None option?

Post by kdvolder »

A bit more trial and error and this is the closest I've gotten so far:

Code: Select all

convert sts512.png -compress none \
    \( -clone 0 -resize 16x16 -compress none \) \
    \( -clone 0 -resize 24x24 -compress none \) \
    \( -clone 0 -resize 32x32 -compress none \) \
    \( -clone 0 -resize 48x48 -compress none \) \
    \( -clone 0 -resize 16x16 -colors 256 -compress none \) \
    \( -clone 0 -resize 24x24 -colors 256 -compress none \) \
    \( -clone 0 -resize 32x32 -colors 256 -compress none \) \
    \( -clone 0 -resize 48x48 -colors 256 -compress none \) \
    -delete 0 sts.ico
The only thing I'm just can't seem get working is the 256x256 resolution image.
It seems as soon as I try to stick *any* images with that resolution into the .ico file
either as 256color palette indexed image or a 'full' image... -compress none is
no longer being obeyed.

E.g this is the simplest command that has this strange behavior:

Code: Select all

convert sts512.png -resize 256x256 -compress none sts.ico

Code: Select all

$ identify -format '%f %p/%n %m %C/%Q %r %G %A %z\n' sts.ico
sts.ico 0/1 ICO Zip/0 DirectClassRGBMatte 256x256 True 8
Note how even though I said '-compress none' the image seems to be stored with zip compression.

Even more funny is that if I add a 256x256 line to my other command at the top,
then all images are suddenly stored compressed.

If I put this line in the middle then all images above are not compressed and all the ones below *are* compressed.

The same also happens if I take a source PNG in 256x256 and convert it simply to a ICO file like so

Code: Select all

convert sts256.png -compress none sts.ico
It seems no matter how I do it... if I add a 256x256 image to my ico file it causes stuff to be compressed.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert not obeying -compress None option?

Post by fmw42 »

What platform? LInux does not support 256x256. See http://www.visualpharm.com/articles/icon_sizes.html
kdvolder
Posts: 5
Joined: 2014-01-27T14:32:19-07:00
Authentication code: 6789

Re: convert not obeying -compress None option?

Post by kdvolder »

I'm running these commands on a Linux system with the intent to create icons for a Windows distribution of our product.

We need to provide icons in different formats compatible with different target OS. I was hoping we can actually produce the windows icons using imagemagic commands on Linux.
This would be very convenient since our CI builds run on Linux boxes. Also my development machine is a Linux box.

I was under the impression that .ico is a rather Windows oriented format so it seems reasonable I'd be able to stick in 256x256 images
even if I'm doing this on Linux. It doesn't really matter that these icons won't be compatible with Linux since they will not actually be used on Linux.

Thanks for your help. If you have any more ideas on what I could try to still get it to work it would be much appreciated.
I'll keep watching this thread.

For the moment though I'm giving up on imagemagick as I'm all out of ideas myself. Looks like I'll need to
fire up a Windows VM and find some native Windows tool to create the icons.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: convert not obeying -compress None option?

Post by fmw42 »

try creating it with your command on Windows IM. If that fails, then submit a bug report on the Bugs forum. Perhaps IM has a bug or limitation, that the developers can fix.

Perhaps some windows user can try to create one with your command.
kdvolder
Posts: 5
Joined: 2014-01-27T14:32:19-07:00
Authentication code: 6789

Re: convert not obeying -compress None option?

Post by kdvolder »

That was a good suggestion.

Installed imagemagic in windows 7 VM and this command seems to work:

Code: Select all

convert sts256.png -compress none ^
    "(" -clone 0 -resize 16x16 -compress none ")" ^
    "(" -clone 0 -resize 24x24 -compress none ")" ^
    "(" -clone 0 -resize 32x32 -compress none ")" ^
    "(" -clone 0 -resize 48x48 -compress none ")" ^
    "(" -clone 0 -resize 16x16 -colors 256 -compress none ")" ^
    "(" -clone 0 -resize 24x24 -colors 256 -compress none ")" ^
    "(" -clone 0 -resize 32x32 -colors 256 -compress none ")" ^
    "(" -clone 0 -resize 48x48 -colors 256 -compress none ")" ^
    "(" -clone 0 -resize 256x256 -compress none ")" ^
    -delete 0 sts.ico
At least the info from 'identify' command looks sane. Will still need to wait for a CI build to verify the icon actually works correctly
on our Windows build.
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: convert not obeying -compress None option?

Post by snibgo »

kdvolder wrote:Version: ImageMagick 6.6.9-7
That is a very old version. I suggest you upgrade.

On v6.8.8-0 Windows 8.1:

Code: Select all

F:\web\im>c:\im\ImageMagick-6.8.8-Q16\convert -size 256x256 xc:none -draw "fill red line 0,0 99,99" x.ico

F:\web\im>c:\im\ImageMagick-6.8.8-Q16\identify -format "%f %p/%n %m %C/%Q %r %G %A %z\n" x.ico
x.ico 0/1 ICO Zip/92 DirectClass sRGB Matte 256x256 True 8

F:\web\im>c:\im\ImageMagick-6.8.8-Q16\convert -size 256x256 xc:none -draw "fillred line 0,0 99,99" -compress none x.ico

F:\web\im>c:\im\ImageMagick-6.8.8-Q16\identify -format "%f %p/%n %m %C/%Q %r %G %A %z\n" x.ico
x.ico 0/1 ICO Undefined/92 DirectClass sRGB Matte 256x256 True 32
snibgo's IM pages: im.snibgo.com
Post Reply