Page 1 of 1

Identify from command line - need help

Posted: 2012-11-01T07:13:05-07:00
by michaelpe
Hello,
I'm trying to detect corrupted JPEG files. I'm running the identify utility using the command line. The option is -verbose. Everything works well: I actually receive
identify.exe: Corrupt JPEG data: premature end of data segment ....
But, I can't pick up this string for the further processing. Standard redirection to text file
identify -verbose file.jpeg > result.txt
prints into a file the whole verbose information, except the error. The error is printed out only to command line.
So if I want to run a batch processing of 100 files and detect how many files were corrupted, I can't do it. Unless I'm missing something...
Any suggestions?

Re: Identify from command line - need help

Posted: 2012-11-01T11:53:03-07:00
by fmw42
try using -quiet -regard-warnings in an if statement, so that you can print out only some message you want.

see
http://www.imagemagick.org/Usage/basics/#controls

try something like this

infile="someimage.jpg"
convert -quiet -regard-warnings $infile null: ||
echo "--- FILE $infile IS NO GOOD ---"

See if that traps it cleaner. You can log the message to a file if you want also. I wrote the result if OK to null: (no image), but you can write it to some other file and add other commands after reading the file, if you want.


PS. This was on unix. I am not sure how to do the conditional on Windows. So see http://www.imagemagick.org/Usage/windows/

Re: Identify from command line - need help

Posted: 2012-11-01T11:57:11-07:00
by snibgo
The error is probably sent to stderr, which is channel 2. Pick it up with:

identify -verbose file.jpg 2>result.txt

Re: Identify from command line - need help

Posted: 2012-11-05T10:10:28-07:00
by michaelpe
Thank you, guys, that was very helpful.