Page 1 of 1
Change image color
Posted: 2017-06-01T03:36:58-07:00
by rpatelob
Is this a bug?
I'm trying to change colour of an image. All colours should be changed except transparent.
Please look at the command.
Code: Select all
convert single_color.png -fuzz 20% -fill red +opaque "#00000000" output.png
#or
convert single_color.png -fuzz 20% -fill red +opaque transparent output.png
It was working on my previous imagemagick version but after upgraded, it seems to be not working.
Version: ImageMagick 7.0.5-9 Q16 x86_64 2017-06-01
http://www.imagemagick.org
Re: Change image color
Posted: 2017-06-01T09:21:23-07:00
by fmw42
They do two different things.
On IM 7, this should work
Code: Select all
magic single_color.png -fuzz 20% -fill red +opaque "#00000000" output.png
or
Code: Select all
magic single_color.png -fuzz 20% -fill red +opaque none output.png
However, in testing it works fine in IM 6.9.8-7 using convert , but does fail in 7.0.5-8 using magick.
The other command with +opaque, changes all colors but red to transparent
Re: Change image color
Posted: 2017-06-01T09:26:55-07:00
by fmw42
I can confirm this bug in IM 7.0.5.8 Mac OS X when compare to IM 6.9.8.7
# create transparent image
Code: Select all
convert logo: -transparent white logot.png
IM 6:
Code: Select all
convert logot.png -fuzz 10% -fill red +opaque none logot_red6.png
IM7: (makes no change to the image)
Code: Select all
magick logot.png -fuzz 10% -fill red +opaque none logot_red7.png
Re: Change image color
Posted: 2017-06-01T09:39:19-07:00
by lettermand
Also confirmed with 7.0.5.9 on cygwin (and breaks lots of scripts)
Re: Change image color
Posted: 2017-06-01T09:47:35-07:00
by fmw42
I can confirm this also on 7.0.5.9 Mac OSX
Re: Change image color
Posted: 2017-06-01T11:40:31-07:00
by magick
Thanks for the problem report. We can reproduce it and will have a patch to fix it in GIT master branch @
https://github.com/ImageMagick/ImageMagick later today. The patch will be available in the beta releases of ImageMagick @
http://www.imagemagick.org/download/beta/ by sometime tomorrow.
Re: Change image color
Posted: 2017-06-01T21:51:04-07:00
by rpatelob
Thank you for consider it.
Re: Change image color
Posted: 2019-01-15T04:35:50-07:00
by shoansa
It seems that this problem still exists in the latest release of "
ImageMagick-7.0.8-Q16". Below are actions performed.
1) magick input.png -fuzz 100% -fill red -opaque white output.png (With this get same output as in input).
2) magick input.png -fuzz 100% -fill red +opaque white output.png (If I change -opaque to +opaque, color get filled on whole image)
Attaching input and expected images.
Input image
expected image
Please help.
Re: Change image color
Posted: 2019-01-15T15:22:39-07:00
by fmw42
Your command should not work. You are trying to change all colors by using -fuzz 100% and your are trying to change white, not black to red. This works fine for me on IM 7.0.8.23 Q16 Mac OSX Sierra, thought I get pure red and not your lighter reddish color.
Code: Select all
magick input.png -fuzz 50% -fill red -opaque black output.png
Re: Change image color
Posted: 2019-01-17T02:58:30-07:00
by shoansa
Thank you Fred to correct me.
One more query, I am trying to combine three commands in one to achieve drop shadow effect in image. Below command used to work in orlder version but not working in current version. Can you please correct me where I am doing wrong? Below is the command.
magick -respect-parentheses ( input.png -fuzz 50% -fill red -opaque black -quality 20 ) ( -clone 0 -background rgb(53,63,124) -shadow 50x1+2+1 ) ( -clone 0 -background black -shadow 30x1-2-1 ) ( -clone 0 -clone 1 -clone 2 -reverse -background none -layers merge -quality 20 +repage +write output.png )
Re: Change image color
Posted: 2019-01-17T15:23:19-07:00
by fmw42
-respect-parentheses apparently was not converted to IM 7. Use -respect-parenthesis. Also you need to add a null: after your last parenthesis. So in Windows IM 7 with ^ as new line characters to make it more readable, try
Code: Select all
magick -respect-parenthesis ^
( input.png -fuzz 50% -fill red -opaque black -quality 20 ) ^
( -clone 0 -background rgb(53,63,124) -shadow 50x1+2+1 ) ^
( -clone 0 -background black -shadow 30x1-2-1 ) ^
( -clone 0 -clone 1 -clone 2 -reverse -background none -layers merge -quality 20 +repage +write output.png ) ^
null:
Does that work the way you want? If not, show us the input and the output and tell us what is wrong?
Re: Change image color
Posted: 2019-08-19T05:20:51-07:00
by shoansa
Hi Fred,
Thanks, that work.
With the updated version of IM, output image gets pixelated. Below is the detail.
Version= ImageMagick-7.0.8-Q16
OS= Windows 7, 64 bit
Re: Change image color
Posted: 2019-08-19T09:55:22-07:00
by fmw42
Please show your input and output images and the command you used. Also what is the exact version of ImageMagick 7.0.8.x
If this was the last command I showed, then it seems to work fine for me on IM 7.0.8.61 Q16 Mac OSX.
Unix syntax:
Code: Select all
magick -respect-parenthesis \
\( input_text.png -fuzz 50% -fill red -opaque black -quality 20 \) \
\( -clone 0 -background "rgb(53,63,124)" -shadow 50x1+2+1 \) \
\( -clone 0 -background black -shadow 30x1-2-1 \) \
\( -clone 0 -clone 1 -clone 2 -reverse -background none -layers merge -quality 20 +repage +write output_text.png \) \
null:
Re: Change image color
Posted: 2019-08-19T22:18:47-07:00
by shoansa
Version
Version: ImageMagick 7.0.8-60 Q16 x64 2019-08-10
http://www.imagemagick.org
Copyright: Copyright (C) 1999-2018 ImageMagick Studio LLC
License:
http://www.imagemagick.org/script/license.php
Visual C++: 180040629
Features: Cipher DPC Modules OpenCL OpenMP(2.0)
Delegates (built-in): bzlib cairo flif freetype gslib heic jng jp2 jpeg lcms lqr lzma openexr pangocairo png ps raw rsvg tiff webp xml zlib
Command:
magick -respect-parenthesis ( input.png -fuzz 99% -fill rgb(225,225,225) -opaque black -quality 20 ) ( -clone 0 -background "rgb(53,63,124)" -shadow 50x1+2+1 ) ( -clone 0 -background black -shadow 30x1-2-1 ) ( -clone 0 -clone 1 -clone 2 -reverse -background none -layers merge -quality 20 +repage +write output.png ) null:
Input
Output
Expected output
The expected output is generated from the old version of IM (ImageMagick-6.9.1-Q16-HDRI)
Re: Change image color
Posted: 2019-08-20T09:22:40-07:00
by fmw42
I get your same bad result on IM 7.0.8.61 Q16 HDRI Mac OSX with the following command:
Code: Select all
magick -respect-parenthesis \
\( 6214291349a70-af1a-431a-8186-0ced1d8e8c4d.png -fuzz 50% -fill "rgb(225,225,225)" -opaque black -quality 20 \) \
\( -clone 0 -background "rgb(53,63,124)" -shadow 50x1+2+1 \) \
\( -clone 0 -background black -shadow 30x1-2-1 \) \
\( -clone 0 -clone 1 -clone 2 -reverse -background none -layers merge -quality 20 +repage +write output_text.png \) \
null:
Likewise using IM 6.9.10.61
and 6.9.1.7 Q16 Mac OSX (both non-HDR) with
Code: Select all
convert -respect-parenthesis \
\( 6214291349a70-af1a-431a-8186-0ced1d8e8c4d.png -fuzz 50% -fill "rgb(225,225,225)" -opaque black -quality 20 \) \
\( -clone 0 -background "rgb(53,63,124)" -shadow 50x1+2+1 \) \
\( -clone 0 -background black -shadow 30x1-2-1 \) \
\( -clone 0 -clone 1 -clone 2 -reverse -background none -layers merge -quality 20 +repage +write output_text6.png \) \
null:
I am not sure how you got a better result because your are using -fuzz to do the color change. That will produce stair stepping unless you use some blur to antialias.