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

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
32d2d7ee
Posts: 11
Joined: 2016-09-19T01:00:08-07:00
Authentication code: 1151

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

Post 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
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post 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
snibgo's IM pages: im.snibgo.com
Post Reply