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?
Identify from command line - need help
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: Identify from command line - need help
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/
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/
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: Identify from command line - need help
The error is probably sent to stderr, which is channel 2. Pick it up with:
identify -verbose file.jpg 2>result.txt
identify -verbose file.jpg 2>result.txt
snibgo's IM pages: im.snibgo.com
Re: Identify from command line - need help
Thank you, guys, that was very helpful.