Page 1 of 1

Need hints for the equivalent of cmd line tool 'identify'

Posted: 2017-06-27T05:51:31-07:00
by McA
Hi all,

after hours of searching the documentation, the web and here in the forum, I'm really stuck.
Therefore I want to aks for a hint to find the right answer. I would like to implement the following command line into the PerlMagick' s equivalent:

identify -channel Gray -format "%[fx:255*mean]"

Can someone please tell me which methods have to be called to get the same information in perl using Image::Magick.
(I know that I could call this command from perl, which I want to avoid.)

Any help and pointers really appreciated.

Best regards

Re: Need hints for the equivalent of cmd line tool 'identify'

Posted: 2017-06-27T06:33:54-07:00
by snibgo
That command is equivalent to:

Code: Select all

convert input.ext -colorspace Gray -format "%[fx:255*mean.r]" info:
The documentation at tells you how to do "-colorspace" and "-format".

Re: Need hints for the equivalent of cmd line tool 'identify'

Posted: 2017-06-27T07:16:07-07:00
by McA
As I wrote: I read the documentation. Probably I'm too stupid to map the command line options to the right method calls. But this is exacly what I don't get together. And that what the reason I opened an account here and posted a question in the hope to get some further hints. Yes, there was a 20/80 chance to get this standard reply. So' it seems I'm in bad luck. IMHO there is nowhere an explicit documentation mapping the functions triggered by the command line options of 'identify' to the equivalent methods of Image::Magick.

Anyways, following you hint: Searching in the document for '-colorspace' I get NOTHING. Let's search for 'colorspace'.
1) Heading "Manipulate an Image": Method Colorspace: So let's try, not knowing if it's the same that is done by the cmd line option.

Code: Select all

my $file = 'gesicht.jpg';
my $pic = Image::Magick->new;
Now I get:

Code: Select all

Your vendor has not defined PerlMagick macro main::Colorspace, used at line 17.
Puh, so I don't know whether I tried the right thing or simply ran into a distribution packaging hell. Mmmh.

So, second finding:
Quantize could be another guess. Let's try it. Ok , it seems that something was converted. Is it the same functionality as the cmd line option? I don't know. It's not documented, is it?

So search for '-format': You know it: No match at all.
Let's search for 'format'. Now I get several results.

Code: Select all

$width = $image->Get('format');
doesn't seem to be the right thing. Or is it? As I want information about a file, a method 'Get' seems not too bad. Mmh.
Let's search further. I find something about Blobs. That doesn't seem to be the right thing.
Continue. 'Ping'. No.
Continue. QueryFont? No.
Continue. QueryFormat? No.
Continue. MagickToMime()? Doesn't seem to be a right hit neither.
Continue. Some examples and other stuff with word 'format', which seem not to be related.
Now I'm through the document.

Now, please: Where do I find the documentation for the equivalent method calls needed to do exact the same what is done with

Code: Select all

-format "%[fx:255*mean]"
on the command line tool 'identify''?

Thank you all in advance