Page 1 of 1

-colorize loses transparency. Bug?

Posted: 2013-07-15T05:06:22-07:00
by tkagerer
Hey guys! I have this PNG file: http://loft9211.serverloft.de/icon.png (with transparency)

if i do

Code: Select all

convert icon.png -fill '#93117e' -colorize 100% output.png
I get this (http://loft9211.serverloft.de/output.png) on one server (ImageMagick 6.7.7-10 2012-11-06 Q16) and that (http://85.25.147.10/output.png) on the other server - what i expected (ImageMagick 6.6.0-4 2012-05-02 Q16)

Have there been changes between these versions or is this a bug and how can I get around that problem?

Thanks!

P.S.:
I found this thread: viewtopic.php?f=1&t=23552#p99415 where fmw42 suggests to use -alpha off and -alpha on

But if I use

Code: Select all

convert icon.png -alpha off -fill '#93117e' -colorize 100% -alpha on output.png
or

Code: Select all

convert -background transparent icon.png -alpha off -fill '#93117e' -colorize 100% -alpha on output.png
it doesn't work neither :?

P.S.S.:
This thread viewtopic.php?f=3&t=23370 is also about this topic and again

Code: Select all

 convert partiallytransparentimage -alpha off -fill red -colorize 100% -alpha on output
doesn't work neither ...

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T08:44:55-07:00
by snibgo
Taking http://85.25.147.10/output.png as the desired result, purple letters on a white background, I get that result using ...

Code: Select all

convert icon.png -alpha off -fill #93117e -colorize 100 -alpha on output.png
... for a variety of versions, including 6.6.0-8, 6.7.9-6 and 6.8.6-0.

Note that "-colorize" takes a number that is automatically a percentage. It shouldn't have a % sign, but it seems harmless.

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T08:53:24-07:00
by tkagerer
Thanks for your reply.

I just executed your command

Code: Select all

convert icon.png -alpha off -fill "#93117e" -colorize 100 -alpha on output2.png
and this is the result: http://loft9211.serverloft.de/output2.png - still w/o transparency :-/

Exact version information:

Version: ImageMagick 6.7.7-10 2012-11-06 Q16 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2012 ImageMagick Studio LLC
Features: OpenMP

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T08:56:12-07:00
by tkagerer
So will I have to upgrade to a newer version or is there any workaround to archive the desired result?

I am using Debian 7.1 and I am not keen on upgrading to a newer version for one application if it is not absolutely necessary.

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T09:12:00-07:00
by snibgo
I don't have 6.7.7-10, but may be able to find a solution that does what you want on that version.

But I don't know what you want. icon.png has aliased black letters on a transparent background. The background is transparent black near the letters; otherwise transparent white.

What result do you want? Purple letters on a transparent background, or what?

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T09:14:49-07:00
by tkagerer
snibgo wrote:I don't have 6.7.7-10, but may be able to find a solution that does what you want on that version.

But I don't know what you want. icon.png has aliased black letters on a transparent background. The background is transparent black near the letters; otherwise transparent white.

What result do you want? Purple letters on a transparent background, or what?
Exactly! I want purple letters on a transparent background, yes :D

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T09:27:01-07:00
by snibgo
Try:

Code: Select all

convert icon.png -fill #93117e -alpha off -opaque Black -alpha on output.png

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T09:35:59-07:00
by tkagerer
snibgo wrote:Try:

Code: Select all

convert icon.png -fill #93117e -alpha off -opaque Black -alpha on output.png
Thanks! That's it!

I tried opaque Black before, but i forgot to disable alpha.

Thank you very much!!

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T10:57:32-07:00
by tkagerer
Just another issue...

If the image is grayscale this is the output http://loft9211.serverloft.de/output3.png

I tried to solve the problem by converting it to TrueColor, but my approach doesn't seem to work ...

Code: Select all

convert input.png -type TrueColorMatte -fill "#93117e" -alpha off -opaque Black -alpha on -define png:color-type=6 output3.png
Tom

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T11:08:27-07:00
by snibgo
Apart from size, what's the difference between output3.png and output.png?

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T11:46:06-07:00
by tkagerer
snibgo wrote:Apart from size, what's the difference between output3.png and output.png?
Well the colorcode of output3.png is wrong, if I ask photoshop

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T12:05:35-07:00
by fmw42
You cannot trust PS because it may be changing the color profile. You need to be sure you are importing with the same color profile or lack of one. Open the Color Settings panel and be sure you know what is there.

You also have a very strange image. If you do


convert icon.png -alpha off icon_aoff.png
convert icon.png -alpha extract icon_alpha.png

You will see that the base image (aoff) is white with a black patch in the middle.
All the text is in the alpha channel as 8 bit gray.

Perhaps this is what you want

convert icon.png \( -clone 0 -fill "#93117e" -colorize 100 \) \( -clone 0 -alpha extract \) -delete 0 -alpha off -compose copy_opacity -composite result.png

Re: -colorize loses transparency. Bug?

Posted: 2013-07-15T23:19:22-07:00
by tkagerer
fmw42 wrote:You cannot trust PS because it may be changing the color profile. You need to be sure you are importing with the same color profile or lack of one. Open the Color Settings panel and be sure you know what is there.

You also have a very strange image. If you do


convert icon.png -alpha off icon_aoff.png
convert icon.png -alpha extract icon_alpha.png

You will see that the base image (aoff) is white with a black patch in the middle.
All the text is in the alpha channel as 8 bit gray.
Well you guys helped me enough - so if this is not possible or you don't wanna waste any more time, I will stay with the fact, that one has to use RGB PNGs.

But if you want to still think about the problem: The output image obviously has another color (profile?)! This image is made for the web and the output image is lighter than it should be (I use Google Chrome - if this makes any difference?)...
fmw42 wrote: Perhaps this is what you want

convert icon.png \( -clone 0 -fill "#93117e" -colorize 100 \) \( -clone 0 -alpha extract \) -delete 0 -alpha off -compose copy_opacity -composite result.png
Mhh not really - now the image has a complet different color?
http://loft9211.serverloft.de/result.png

Re: -colorize loses transparency. Bug?

Posted: 2013-07-16T00:03:47-07:00
by snibgo
tkagerer wrote:This image is made for the web and the output image is lighter than it should be (I use Google Chrome - if this makes any difference?)...
I don't have your old version of IM, or any version of PS, but it might be a gamma problem, aka RGB/sRGB. If so, then sprinkling "-set colorspace sRGB" or "-set colorspace RGB" in conversions might help.

Re: -colorize loses transparency. Bug?

Posted: 2013-07-16T00:40:59-07:00
by tkagerer
snibgo wrote:
tkagerer wrote:This image is made for the web and the output image is lighter than it should be (I use Google Chrome - if this makes any difference?)...
I don't have your old version of IM, or any version of PS, but it might be a gamma problem, aka RGB/sRGB. If so, then sprinkling "-set colorspace sRGB" or "-set colorspace RGB" in conversions might help.
Damn that did it!

You guys are all wizards, thanks a lot! :D :D :D