Page 1 of 1

Convert %[pixel:p{10,10}] to transparent

Posted: 2016-09-19T01:29:13-07:00
by 32d2d7ee
I would like replace the color of the background, based on the color of pixel 10,10, to tranpsarency.

I managed the get the color of pixel 10, 10 by issueing:

Code: Select all

convert logo: -format %[pixel:p{10,10}] info:
white
I also manage to replace the white in the logo to transparency by:

Code: Select all

convert logo: -transparent white logo.png
However, somehow the combination does not work. What am I doing wrong?
Both on Windows and Mac I can not get it to work.
I tried with and without quotes ...
convert logo: -transparent %[pixel:p{10,10}] logo.png
convert.exe: unrecognized color `%[pixel:p{10,10}]' @ warning/color.c/GetColorCompliance/1045.

convert logo: -transparent "%[pixel:p{10,10}]" logo.png
convert.exe: unrecognized color `%[pixel:p{10,10}]' @ warning/color.c/GetColorCompliance/1045.

convert -version
Version: ImageMagick 6.8.8-10 Q16 x86 2014-03-25 http://www.imagemagick.org
Copyright: Copyright (C) 1999-2014 ImageMagick Studio LLC
Features: DPC OpenMP
Delegates: bzlib cairo freetype jbig jng jp2 jpeg lcms lqr pangocairo png ps rsvg tiff webp xml zlib

Re: Convert %[pixel:p{10,10}] to transparent

Posted: 2016-09-19T01:46:46-07:00
by snibgo
"white" is a colour constant. "%[pixel:p{10,10}]" is a colour expression. In v6, "-transparent" needs a colour constant.

EDIT: I should add, in v7 "magick", you can use that colour expression:

Code: Select all

magick logo: -transparent "%[pixel:p{10,10}]" logo.png