ohmage / server

The ohmage server application.
37 stars 25 forks source link

ohmage 2.x: Image's getBufferedImage() does not catch IllegalArgumentException exceptions #831

Closed stevenolen closed 9 years ago

stevenolen commented 9 years ago

IllegalArgumentException can be thrown by ImageIO.read when it finds a partially corrupt image. While it may be better to use an alternative image reader (or an ImageIO plugin) which can handle processing the corrupt(ish) image, we need to at least catch this exception. Currently, a bug in AsyncImageProcessor (#830) paired with this lack of catching results in a never-ending queue of images to be processed -- where the images are also opened on the filesystem over and over.

stevenolen commented 9 years ago

an example of this happening in the wild with funky exif data:

Exception in thread "Thread-7" java.lang.IllegalArgumentException: Numbers of source Raster bands and source color space components do not match
        at java.awt.image.ColorConvertOp.filter(ColorConvertOp.java:482)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.acceptPixels(JPEGImageReader.java:1263)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1231)
        at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1034)
        at javax.imageio.ImageIO.read(ImageIO.java:1448)
        at javax.imageio.ImageIO.read(ImageIO.java:1352)
        at org.ohmage.domain.Image$ImageData.getBufferedImage(Image.java:627)
        at org.ohmage.domain.Image.validate(Image.java:749)
        at org.ohmage.cache.AsyncImageProcessor$ImageProcessor.processImage(AsyncImageProcessor.java:144)
        at org.ohmage.cache.AsyncImageProcessor$ImageProcessor.run(AsyncImageProcessor.java:129)
stevenolen commented 9 years ago

oh, and the file that broke it: https://web.ohmage.org/~snolen/misc/4d065330-b7c7-437f-822f-c6513408e634.jpg

here's the exif output for this file:

EXIF tags in '4d065330-b7c7-437f-822f-c6513408e634.jpg' ('Motorola' byte order):
--------------------+----------------------------------------------------------
Tag                 |Value
--------------------+----------------------------------------------------------
Image Width         |1868
Image Length        |2608
Bits per Sample     |8, 8, 8, 8
Photometric Interpre|CMYK
Samples per Pixel   |4
X-Resolution        |72
Y-Resolution        |72
Resolution Unit     |Inch
Software            |Paint.NET v3.5.11
Date and Time       |2014:07:15 22:02:47
Exif Version        |Exif Version 2.21
Pixel X Dimension   |934
Pixel Y Dimension   |1304
FlashPixVersion     |FlashPix Version 1.0
Color Space         |Internal error (unknown value 65535)
--------------------+----------------------------------------------------------