Hi all !
When I use "identify -verbose" on an image, I have a "Type" field that tells whether the image is Palette, PaletteMatte, TrueColor, TrueColorMate, etc...
How do I get only this information with "identify -format" ?
Thanks a lot !
Edit : Just to make the point clear... I have a huge bunch of files, some are "Palette", some are "TrueColor", some are "TrueColorMatte" and some "PaletteMatte". I need to identify the "PaletteMatte" ones (probably from vbscript, with the activex)
Get image "Type" with identify ?
Re: Get image "Type" with identify ?
Try -format %r.
Re: Get image "Type" with identify ?
Thanks for your answer.
%r gives me "DirectClassRGB".
That looks like a combination of the "Class" and "ColorSpace" fields from the -verbose output, but that's not what I am looking for.
%r gives me "DirectClassRGB".
That looks like a combination of the "Class" and "ColorSpace" fields from the -verbose output, but that's not what I am looking for.
Re: Get image "Type" with identify ?
The -format option only returns readily available metadata that does not require a pass over the image pixels. What you want, the image type, requires a pass over the image pixels which can be expensive and is only available with the -verbose option. You can write a shell script to extract the image type from the verbose output or use one of the MagickCore API wrappers such as PerlMagick. With just a few lines in the PerlMagick script it can return the image type.
Re: Get image "Type" with identify ?
Not the best way to do this but using php this will work:
Code: Select all
<?php
$sourcefile = "imagemagick/original_images/sunflower.jpg";
$cmd = "identify -verbose ".$sourcefile;
exec( "$cmd 2>&1", &$o, $r );
$return = ( "\n<pre>\n".join( "\n", $o )."\n</pre>\n" );
$start = strpos( $return, "Type:" );
$result = substr( $return, $start );
$length = strpos( $result, "\n" );
$result = substr( $result, 5, $length-5 );
echo "Type = $result";
?>
Re: Get image "Type" with identify ?
Oh OK you just meant extracting the information from the "verbose" output.
I can do that.
Thanks for your help guys !
I can do that.
Thanks for your help guys !