X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Ffanfix%2FDataLoader.java;h=395f68314cc7caf131295d899bb179167033c052;hb=b9ce9cad4a94e7c88770d5f7ac6cf4f200e336de;hp=25300130116214d8202bc88e1acc83de98addf3d;hpb=851dd5388802907146e88c3f6b9e68094e73693e;p=fanfix.git diff --git a/src/be/nikiroo/fanfix/DataLoader.java b/src/be/nikiroo/fanfix/DataLoader.java index 2530013..395f683 100644 --- a/src/be/nikiroo/fanfix/DataLoader.java +++ b/src/be/nikiroo/fanfix/DataLoader.java @@ -252,19 +252,24 @@ public class DataLoader { try { String format = Instance.getConfig() .getString(Config.IMAGE_FORMAT_CONTENT).toLowerCase(); - boolean ok = ImageIO.write(image, format, target); - if (!ok) { - // Some formats are not reliable - // Second change: PNG - if (!format.equals("png")) { - ok = ImageIO.write(image, "png", target); - } - if (!ok) { - throw new IOException( - "Cannot find a writer for this image and format: " - + format); - } + boolean ok = false; + try { + ok = ImageIO.write(image, format, target); + } catch (IOException e) { + ok = false; + } + + // Some formats are not reliable + // Second change: PNG + if (!ok && !format.equals("png")) { + ok = ImageIO.write(image, "png", target); + } + + if (!ok) { + throw new IOException( + "Cannot find a writer for this image and format: " + + format); } } catch (IOException e) { throw new IOException("Cannot write image to " + target, e);