Get detailed image info using ImageMagick

Discuss and share scripts and script files...
Post Reply
tgrand
Posts: 17
Joined: 03 Oct 2008 20:23

Get detailed image info using ImageMagick

Post by tgrand »

I just wrote the following script to get detailed info for a selected image file using ImageMagick's identify utility:

Code: Select all

::run "cmd /c """"c:\Program Files (x86)\ImageMagick-6.7.7-Q8\identify.exe"" -verbose ""<curitem>"" > c:\temp\imginfo.txt""", , 1; open "c:\temp\imginfo.txt";
This script runs identify on the selected file, redirects the output to a text file, waits for that to finish, and then opens the text file. If you want to use this script, you'll need to edit the paths to suit your preferences.

Here's an example of the resolved command line that actually gets executed:

Code: Select all

cmd /c ""c:\Program Files (x86)\ImageMagick-6.7.7-Q8\identify.exe" -verbose "c:\test images\crazy image.jpg" > c:\temp\imginfo.txt"
This script demonstrates the following:

1. Redirecting output of a program to a file (must run the program via cmd)
2. Running a program with cmd when the program's path has a space in it
3. Passing multiple parameters to a program run via cmd, including parameters that need to be quoted
4. Calling cmd so that it closes when finished (/c parameter)
5. Waiting for cmd to finish before proceeding to the next command in the script (, , 1 at the end of the run command)
6. Quotes quotes quotes quotes quotes quotes quotes quotes!!!!

Hopefully someone will find this useful when trying to come up with their own script to do something similar.

admin
Site Admin
Posts: 65331
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Get detailed image info using ImageMagick

Post by admin »

What kind of info is that? Got a screenshot?

tgrand
Posts: 17
Joined: 03 Oct 2008 20:23

Re: Get detailed image info using ImageMagick

Post by tgrand »

Very detailed info. Here's an example of the output for a CMYK JPEG with an embedded color profile:

Code: Select all

Image: c:\temp\CMYK.jpg
  Format: JPEG (Joint Photographic Experts Group JFIF format)
  Class: DirectClass
  Geometry: 900x900+0+0
  Resolution: 300x300
  Print size: 3x3
  Units: PixelsPerInch
  Type: ColorSeparation
  Endianess: Undefined
  Colorspace: CMYK
  Depth: 8-bit
  Channel depth:
    cyan: 8-bit
    magenta: 8-bit
    yellow: 8-bit
    black: 8-bit
  Channel statistics:
    Cyan:
      min: 0 (0)
      max: 178 (0.698039)
      mean: 76.6269 (0.300498)
      standard deviation: 38.8284 (0.152268)
      kurtosis: -0.860701
      skewness: 0.237957
    Magenta:
      min: 0 (0)
      max: 124 (0.486275)
      mean: 34.6102 (0.135726)
      standard deviation: 25.6791 (0.100702)
      kurtosis: -0.641929
      skewness: 0.496008
    Yellow:
      min: 0 (0)
      max: 217 (0.85098)
      mean: 145.573 (0.570875)
      standard deviation: 44.2534 (0.173543)
      kurtosis: -0.0455001
      skewness: -0.528856
    Black:
      min: 0 (0)
      max: 161 (0.631373)
      mean: 9.52601 (0.0373569)
      standard deviation: 19.0497 (0.0747046)
      kurtosis: 8.30981
      skewness: 2.73197
  Image statistics:
    Overall:
      min: 0 (0)
      max: 217 (0.85098)
      mean: 66.5841 (0.261114)
      standard deviation: 33.4974 (0.131363)
      kurtosis: 23.8739
      skewness: 4.35594
  Total ink density: 237%
  Rendering intent: Undefined
  Gamma: 1
  Interlace: None
  Background color: cmyk(255,255,255,0)
  Border color: cmyk(223,223,223,0)
  Matte color: cmyk(189,189,189,0)
  Transparent color: cmyk(0,0,0,0)
  Compose: Over
  Page geometry: 900x900+0+0
  Dispose: Undefined
  Iterations: 0
  Compression: JPEG
  Quality: 99
  Orientation: TopLeft
  Properties:
    date:create: 2012-06-22T11:40:34-04:00
    date:modify: 2012-05-24T14:50:06-04:00
    exif:BitsPerSample: 8, 8, 8, 8
    exif:ColorSpace: 65535
    exif:Compression: 6
    exif:DateTime: 2012:05:24 14:50:03
    exif:ExifImageLength: 900
    exif:ExifImageWidth: 900
    exif:ExifOffset: 232
    exif:ExifVersion: 48, 50, 50, 49
    exif:ImageLength: 904
    exif:ImageWidth: 904
    exif:JPEGInterchangeFormat: 382
    exif:JPEGInterchangeFormatLength: 12849
    exif:Orientation: 1
    exif:PhotometricInterpretation: 5
    exif:ResolutionUnit: 2
    exif:SamplesPerPixel: 4
    exif:Software: Adobe Photoshop CS5.1 Windows
    exif:XResolution: 3000000/10000
    exif:YResolution: 3000000/10000
    jpeg:colorspace: 4
    jpeg:sampling-factor: 1x1,1x1,1x1,1x1
    signature: 55af1b77935f19df270cd86f38c840dbb393d2b3178ca6a65ded107f823cf875
    xmpMM:DerivedFrom: 
  Profiles:
    Profile-8bim: 14988 bytes
    Profile-exif: 13237 bytes
    Profile-icc: 557168 bytes
      Description: U.S. Web Coated (SWOP) v2
      Manufacturer: U.S. Web Coated (SWOP) v2
      Model: U.S. Web Coated (SWOP) v2
      Copyright: Copyright 2000 Adobe Systems, Inc.
    Profile-iptc: 15 bytes
      City[1,90]: 0x00000000: 254700                                        -%
      unknown[2,0]: 
    Profile-xmp: 3866 bytes
  Artifacts:
    filename: c:\temp\CMYK.jpg
    verbose: true
  Tainted: False
  Filesize: 1.839MB
  Number pixels: 810K
  Pixels per second: 12.86MB
  User time: 0.062u
  Elapsed time: 0:01.062
  Version: ImageMagick 6.7.7-6 2012-06-03 Q8 http://www.imagemagick.org

admin
Site Admin
Posts: 65331
Joined: 22 May 2004 16:48
Location: Win8.1, Win10, Win11, all @100%
Contact:

Re: Get detailed image info using ImageMagick

Post by admin »

Wow, that's detailed! kurtosis... my new word for today.

And thanks for the cool script!

xman
Posts: 133
Joined: 28 Nov 2009 22:57

Re: Get detailed image info using ImageMagick

Post by xman »

Since ImageMagick came up, here is my own multi-purpose script (note, that you need to search & replace paths with your own):

Code: Select all

"Identify"
 openwith """cmd"" /K <xydrive>\Apps\Graphics\ImageMagick\identify.exe <items>", s

"Identify (Verbose)"
 openwith """cmd"" /K <xydrive>\Apps\Graphics\ImageMagick\identify.exe -verbose <items>", s
-

"Convert to PNG8"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -colors 256 -depth 8 -format PNG <items>", s

"Convert to PNG8 (No Dither)"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" +dither -colors 256 -depth 8 -format png <items>", s

"Convert to PNG32"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format PNG <items>", s

"Convert to JPEG"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format jpg <items>", s

"Convert to JP2"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format jp2 <items>", s

"Convert to TIFF"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format tif <items>", s

"Convert to GIF"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format gif <items>", s

"Convert to BMP"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format bmp <items>", s

"Convert to ICO"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -format ico <items>", s

-

"Reduce Colors to 256"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -colors 256 <items>", s

"Reduce Colors to 256 (No Dither)"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" +dither -colors 256 <items>", s

"Reduce Colors to ..."
 $colors = input("Enter new number of colors!", "", "256");
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -colors $colors <items>", s

"Reduce Colors to ... (No Dither)"
 $colors = input("Enter new number of colors!", "", "256");
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" +dither -colors $colors <items>", s

-
"Resize to 50%"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -resize 50% <items>", s

"Resize to 25%"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -resize 25% <items>", s

"Resize to 200%"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -resize 200% <items>", s

"Resize to ..."
 $percent = input("Enter new size in percent!", "", "100");
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -resize $percent% <items>", s


-
"Rotate Left"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -rotate ""-90"" <items>", s

"Rotate Right"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -rotate ""+90"" <items>", s

"Rotate 180"
 openwith """<xydrive>\Apps\Graphics\ImageMagick\mogrify.exe"" -rotate ""+180"" <items>", s

Post Reply