// Some formats are not reliable
// Second chance: PNG
if (!ok && !format.equals("png")) {
- ok = ImageIO.write(image, "png", target);
+ try {
+ ok = ImageIO.write(image, "png", target);
+ } catch (IllegalArgumentException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOException("Undocumented exception occured, "
+ + "converting to IOException", e);
+ }
}
if (!ok) {
}
in.reset();
- BufferedImage image = ImageIO.read(in);
+ BufferedImage image;
+ try {
+ image = ImageIO.read(in);
+ } catch (IllegalArgumentException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IOException("Undocumented exception occured, "
+ + "converting to IOException", e);
+ }
if (image == null) {
throw new IOException("Failed to convert input to image");