Page 1 of 1

How machine detects corrupted image automatically??

Posted: 2007-02-18T23:01:30-07:00
by pkashrai
When I wanted to identify corrupted image, using command line:

Code: Select all

identify -verbose corrupt.jpg
the program ends with the last messages
identify: Premature end of JPEG file 'corrupt.jpg'.
identify: Corrupt JPEG data: premature end of data segment 'corrupt.jpg'.

As I think, this gives the image is corrupted to the viewer.But now I wanted the machine to detect the corrupted image automatically as soon as the image is downloaded(e-mail attachments). What should I do? Is there any commands so that the machine detects the corrupted image? Please help!!


With Regards
Prakash Rai

Re: How machine detects corrupted image automatically??

Posted: 2007-02-20T04:17:18-07:00
by shakyamanoj
I also have the same problem.
I issued the command as follows:

Code: Select all

identify -verbose corrupt.jpg >log.txt 2>&1
and I got the log.txt file. But I don't see any EXIT_STATUS there. I am sure that corrupt.jpg file is a corrupted file. How do I know now that the image is corrupted?


/*********************************************************/
This is the log.txt file.
------------------------

corrupt.jpg JPEG 406x491 DirectClass 67kb
identify: Corrupt JPEG data: premature end of data segment `corrupt.jpg'.
Image: corrupt.jpg
Format: JPEG (Joint Photographic Experts Group JFIF format)
Geometry: 406x491
Class: DirectClass
Type: TrueColor
Endianess: Undefined
Colorspace: RGB
Channel depth:
Red: 8-bits
Green: 8-bits
Blue: 8-bits
Channel statistics:
Red:
Min: 0 (0)
Max: 255 (1)
Mean: 172.474 (0.676368)
Standard deviation: 46.0133 (0.180444)
Green:
Min: 0 (0)
Max: 240 (0.941176)
Mean: 126.445 (0.495864)
Standard deviation: 38.8062 (0.152181)
Blue:
Min: 0 (0)
Max: 252 (0.988235)
Mean: 117.174 (0.459504)
Standard deviation: 38.1617 (0.149654)
Colors: 40905
Rendering-intent: Undefined
Resolution: 100x100
Units: PixelsPerInch
Filesize: 67kb
Interlace: None
Background Color: white
Border Color: #DFDFDF
Matte Color: grey74
Dispose: Undefined
Iterations: 0
Compression: JPEG
Quality: 90
Orientation: Undefined
JPEG-Colorspace: 2
JPEG-Sampling-factors: 2x2,1x1,1x1
Signature: d2836de2bccacd9b46d2a3954d4405ef974ae03a8612cac29103dfe8fb6d8f72
Tainted: False
Version: ImageMagick 6.2.3 09/13/05 Q16 http://www.imagemagick.org

/*********************************************************/


Thanks.


Regards,
Manoj Shakya

Re: How machine detects corrupted image automatically??

Posted: 2007-02-21T20:26:31-07:00
by anthony
An exit status is a number the program returns whci hit is finished. Normally it is '0' for okay, or some other value for different error conditions. Shells use it for 'if' statements.

You can see it by looking at the status result of the previosu command in the calling shell.

Code: Select all

  identify file >/dev/null
  echo $?
Or you can us an IF statement in the shell (bash or bourne shell here)

Code: Select all

   if  identify file >/dev/null; then
     echo "the image is good"
   else
      echo "the image is corrupt or known format"
   fi
non of this is ImageMagcik however, but calling shell or language dependant

Re: How machine detects corrupted image automatically??

Posted: 2007-02-21T21:54:51-07:00
by shakyamanoj
Thanks for your response...But still could not able to get the status 1. Can you please try this with the following image? The link for the image is.
http://www.imageboo.com/images/551933corrupt.jpg

Regards,
Manoj Shakya.

Re: How machine detects corrupted image automatically??

Posted: 2007-02-22T19:21:04-07:00
by anthony
Using BASH...

Code: Select all

identify http://www.imageboo.com/images/551933corrupt.jpg
echo $?
The result was 0, whcih is obviously WRONG....

However, Some output appeared on the STDERR so that could be used as a temporary indicator until this status return is fixed.

Re: How machine detects corrupted image automatically??

Posted: 2007-02-22T19:52:53-07:00
by magick
Add -regard-warnings to the command line.

Re: How machine detects corrupted image automatically??

Posted: 2007-02-25T01:29:26-07:00
by shakyamanoj
Thanks a lot. It worked.

regards,
Manoj Shakya.