Page 1 of 1
Why is IM converting image to Grayscale
Posted: 2012-04-15T09:06:08-07:00
by unifant
Hi there, this is a little bit confused.
I have a 24 PNG icon-image with white and transparence and want to fill the colored part with a different color like this:
Code: Select all
convert src.png -fill rgba(0,0,0, 0.0) -colorize 100% target.png
or
Code: Select all
convert src.png -fill rgba(156,222,250, 0.0) -colorize 100% target.png
When i take a color like 0,0,0 (black) then IM saves the image as grayscale image and when i take an other color like 156,222,250 (a light-blue color) then IM makes an indexed grafik of this without any antialiasing.
What's that? How can i solve this problem? I want to get a 24PNG graphic with antialiasing as result.
Thanks a lot!
I'm Using :
ImageMagick 6.7.3-2 2011-10-13 Q16
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T11:35:12-07:00
by fmw42
You need to put quotes around your rgb and rgba color definitions. This is especially the case when you put spaces in the definitions. It is always a good idea to remove spaces in color definitions.
convert src.png -fill "rgba(156,222,250,0.0)" -colorize 100% target.png
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T12:18:13-07:00
by unifant
Thanks for your reply.
Now i have:
Code: Select all
convert src.png -fill "rgba(0,0,0,0.0)" -colorize 100% target.png
but it is still the same problem.
An other idea?
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T12:28:37-07:00
by fmw42
unifant wrote:Thanks for your reply.
Now i have:
Code: Select all
convert src.png -fill "rgba(0,0,0,0.0)" -colorize 100% target.png
but it is still the same problem.
An other idea?
If you want to fill the other colors, then -colorize is not correct. It fills the whole image with that color.
You need to use -fill ... -opaque or -fill +opaque
What color is in the image you want to change and to what color. Here is an example to change white to yellow
convert logo: -fuzz 1% -fill yellow -opaque white logo_tmp1.png
Here is the same example to change everything but white to yellow
convert logo: -fuzz 1% -fill yellow +opaque white logo_tmp1.png
The -fuzz XX% allows for the white to be not pure white, so it gets near colors.
See
http://www.imagemagick.org/Usage/color_basics/#replace
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T13:28:04-07:00
by unifant
Hi,
i don't have a problem with coloring the image. This part works.
I have an icon inside this graphic in white color and the other part is transparent.
This way i color every part of the image, which is not transparent.
My problem is that IM converts the target image to Grayscale-Image when it is black or grey color and makes an indexed image, when it has an other color. The source image is PNG 24.
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T13:30:09-07:00
by fmw42
I think you need to post a link to your image, so we can see what is happening. And please explain how you want this image changed.
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T14:25:51-07:00
by unifant
This one is the original image
http://www.fotoporto.de/imagemagick/search.png
identify -verbose shows this
Code: Select all
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 17x17+0+0
Resolution: 72x72
Print size: 0.236111x0.236111
Units: Undefined
Type: Bilevel
Base type: Bilevel
Endianess: Undefined
Colorspace: RGB
Depth: 8-bit
...
This one comes out, when i use rgba(68,68,68,0.0)
http://www.fotoporto.de/imagemagick/search_gray.png
identify -verbose shows this
Code: Select all
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 17x17+0+0
Resolution: 72x72
Print size: 0.236111x0.236111
Units: Undefined
Type: GrayscaleMatte
Base type: GrayscaleMatte
Endianess: Undefined
Colorspace: Gray
Depth: 8-bit
...
This one is a grayscaled graphic, when i open it in Photoshop. In Browser it looks right.
And finally this one comes out, when i use rgba(156,222,250,0.0)
http://www.fotoporto.de/imagemagick/sea ... htblue.png
identify -verbose shows this
Code: Select all
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 17x17+0+0
Resolution: 72x72
Print size: 0.236111x0.236111
Units: Undefined
Type: Bilevel
Base type: Bilevel
Endianess: Undefined
Colorspace: Gray
Depth: 8-bit
...
This one is an indexed graphic with no antialiasing, when i open it in Photoshop. In Browser it looks right.
It looks like this
http://www.fotoporto.de/imagemagick/sea ... toshop.png
Both should be PNG 24 RGB not grayscaled and not indexed.
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T14:44:15-07:00
by fmw42
If you do not have more than 256 colors, IM will default to palette and if transparency is present then palettematte. That is what I get for:
convert 1search.png -fill "rgba(156,222,250,0.0)" -colorize 100% 1search_blue.png
identify -verbose 1search_blue.png
Image: 1search_blue.png
Format: PNG (Portable Network Graphics)
Class: DirectClass
Geometry: 17x17+0+0
Resolution: 72x72
Print size: 0.236111x0.236111
Units: Undefined
Type: PaletteMatte
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
alpha: 8-bit
I do not get grayscale, except when you specify a gray set of colors.
What version of IM are you using and what platform. The above was using IM 6.7.6.5 Q16 Mac OSX Snow Leopard
Usually you can force it to 32bit color by
convert 1search.png -fill "rgba(156,222,250,0.0)" -colorize 100% PNG32:1search_blue2.png
But that does not seem to work.
This would be a question for the PNG developer, glennrp. He will likely get online sometime later and he can give a better answer.
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T15:14:11-07:00
by unifant
Thanks,
i tried various thinks like
-depth 8
PNG24:target.png
-colorspace RGB
but nothing helped.
I'm using
I'm Using :
ImageMagick 6.7.3-2 2011-10-13 Q16
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2011 ImageMagick Studio LLC
Features: OpenMP
on Mac OSX Lion
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T16:25:29-07:00
by fmw42
colorspace and depth will not help. PNG24 will remove the transparency. you would need PNG32, but I tried that and it did not force to 32 bit truecolor. I also tried by adding -type truecolormatte and also -define png:color-type=6. But they did not help either.
see
http://www.imagemagick.org/Usage/formats/#png
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T21:03:51-07:00
by anthony
By default IM will try to use the BEST image file format to hold the image.
For example palette images, greyscale images, or even 8 bit images if all colors are exactly 8 bit colors.
The -type option is ment to tell coders exactly what type of image it should produce. that is override that automatic handling.
PNG images goes further and provides defines to specify the exact PNG sub-format to use.
See IM Examples, PNG Images, Ouput settings
http://www.imagemagick.org/Usage/formats/#png_formats
Re: Why is IM converting image to Grayscale
Posted: 2012-04-15T21:07:11-07:00
by fmw42
anthony wrote:By default IM will try to use the BEST image file format to hold the image.
For example palette images, greyscale images, or even 8 bit images if all colors are exactly 8 bit colors.
The -type option is ment to tell coders exactly what type of image it should produce. that is override that automatic handling.
PNG images goes further and provides defines to specify the exact PNG sub-format to use.
See IM Examples, PNG Images, Ouput settings
http://www.imagemagick.org/Usage/formats/#png_formats
I tried all that and it did not seem to work for me. Perhaps Glenn can clarify or verify.
Re: Why is IM converting image to Grayscale
Posted: 2012-04-16T01:05:32-07:00
by unifant
Hi,
saving the file as PNG32 seems to work now. No grayscale and not indexed.
Thanks a lot.