Page 1 of 1

[SOLVED] Colorize(blend=>string) [as RGB pctgs; e.g., blend=>'100/0/0']

Posted: 2019-09-21T11:10:53-07:00
by E. Fudd Wabbitwy
I've only been able to find one example:

Code: Select all

blend->'0x20'
from a user's comment on a different method.

I want to read in an existing PNG image (which has transparency) and make the whole thing transparent.

I guess that it should be doable with $image->Colorize(fill=>\@transp_pixelpkt,blend=>string), but I cannot find information about the format for "string".

Searches of the forum and the imagemagick.org website for +blend +string turned up nothing.

Can someone please help?

Thank you.

(Note: It's possible that '0x20' would be interpreted as "0x00000020", hex with the first three '00' pairs associated with 'r,g,b' blend percentages respectively, and '20' referring to 'something or other' to do with 'alpha'.)

Re: Colorize(blend=>string) [what's the format of string?]

Posted: 2019-09-21T11:27:33-07:00
by fmw42
Many ways. Here are two in command line:

Code: Select all

convert image.png -alpha transparent result.png
or

Code: Select all

convert image.png -channel a -evaluate set 0 +channel result.png
See
https://imagemagick.org/Usage/canvas/#blank_pick

Re: Colorize(blend=>string) [what's the format of string?]

Posted: 2019-09-21T11:45:19-07:00
by snibgo
On $image->Colorize, see http://www.imagemagick.org/script/comma ... p#colorize . Perhaps the blend parameter corresponds to the command-line "value".

But "-colorize" can't create transparency.

Re: Colorize(blend=>string) [what's the format of string?]

Posted: 2019-09-21T12:29:26-07:00
by E. Fudd Wabbitwy
@snibgo
https://imagemagick.org/script/perl-mag ... manipulate
lists Method: Colorize() with two parameters, 'fill', and 'blend'

Parameter 'fill' corresponds to the command line's 'value': as you say, it appears to be a color[1], but I looked in vain for a parallel for 'blend'.

@Fred
On the same note, without some kind of "Guidemap" informing PerlMagick users how the command-line translates to Image::Magick calls, the best we can do is guess.

This brings me full circle, I think. I started here by asking if anyone knew of a way to get the Perl modules (Magick.pm and its cohorts) to cough up information about their own methods and parameters.

I Feel It In My Bones that PerlMagick is--some-how--"making command-line calls" to ImageMagick, and if I could--only--find the Rosetta stone for how it is translating PerlMagick methods before doing so, my chatter here would be much reduced.

Notes:
[1] I say "appears" because the writer of the Colorize() method in PerlMagick COULD have added Transparency to what's acceptable to 'fill' and then stripped it out and processed it differently before sending it on to ImageMagick.

Re: Colorize(blend=>string) [what's the format of string?]

Posted: 2019-09-21T12:38:18-07:00
by snibgo
E. Fudd Wabbitwy wrote:Parameter 'fill' corresponds to the command line's 'value': as you say, it appears to be a color[1], ...
I'm not saying that. I expect perl Colorize "fill" corresponds to the CLI "-fill", which is a colour, and perl Colorize "blend" corresponds to CLI "-colorize value", where value is typically a single number but can be three comma-separated numbers.

But I don't use perl or PerlMagick.

Re: Colorize(blend=>string) [what's the format of string?]

Posted: 2019-09-22T11:55:24-07:00
by E. Fudd Wabbitwy
I realized that, having just installed ImageMagick from source and having not removed the compilation working-directory, I had the source to ImageMagick right in front of me!

Here's what I did, in Ubuntu Linux:

Code: Select all

% find ~/ImageMagick-7.0.8-65/ -type f -exec grep -i Colorize\( {} \; -print | grep \.[ch]$
to identify all the .c and .h files containing "[Cc]olorize(", and I judged
~/ImageMagick-7.0.8-65/MagickCore/fx.c
to be most likely.

Inside it, I found this clue:

Code: Select all

ColorizeImage() blends the fill color with each pixel in the image.
%  A percentage blend is specified with opacity.  Control the application
%  of different color components by specifying a different percentage for
%  each component (e.g. 90/100/10 is 90% red, 100% green, and 10% blue).
From that, I guessed the format might be blend=>'pct/pct/pct':

Code: Select all

$image->Colorize(fill=>'red',blend=>'100/100/100');
which did the fill I wanted, but as you guessed, did not affect any transparent pixels.

Re: [Solved] Colorize(blend=>string) [as RGB pctgs; e.g., blend=>'100/0/0']

Posted: 2019-09-22T14:53:32-07:00
by snibgo
When searching source code, I suggest you start with PerlMagick\Magick.xs. That shows the call to ColorizeImage(...) A grep of magickcore\*.h finds that function in fx.h.

Re: [SOLVED] Colorize(blend=>string) [as RGB pctgs; e.g., blend=>'100/0/0']

Posted: 2019-09-24T06:17:48-07:00
by E. Fudd Wabbitwy
I took your advice and visited, and I recall that I'd been there before, hunting for 'blend', but didn't see the forest for the trees.

It is exactly--half of--what I wanted:
The Definitive List of ImageMagick Methods That Can Be Called From PerlMagick/Image::Magick Code.

I still need, though, to hunt down The Definitive Formats of the Parameters That Go With Them (strings, especially).