Get detailed image info using ImageMagick
Posted: 22 Jun 2012 16:47
I just wrote the following script to get detailed info for a selected image file using ImageMagick's identify utility:
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:
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.
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";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"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.