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

PerlMagick is an object-oriented Perl interface to ImageMagick. Use this forum to discuss, make suggestions about, or report bugs concerning PerlMagick.
Post Reply
McA
Posts: 2
Joined: 2017-06-27T05:42:47-07:00
Authentication code: 1151

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

Post by McA » 2017-06-27T05:51:31-07:00

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
Andreas

snibgo
Posts: 9378
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo » 2017-06-27T06:33:54-07:00

That command is equivalent to:

Code: Select all

convert input.ext -colorspace Gray -format "%[fx:255*mean.r]" info:
The documentation at http://www.imagemagick.org/script/perl-magick.php tells you how to do "-colorspace" and "-format".
snibgo's IM pages: im.snibgo.com

McA
Posts: 2
Joined: 2017-06-27T05:42:47-07:00
Authentication code: 1151

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

Post by McA » 2017-06-27T07:16:07-07:00

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;
$pic->Read($file);
$pic->Colorspace('Gray');
Now I get:

Code: Select all

Your vendor has not defined PerlMagick macro main::Colorspace, used at am002.pl 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
Andreas

Post Reply