import java.io.InputStream;
import java.util.stream.Stream;
-import javax.imageio.ImageIO;
-
import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
import be.nikiroo.utils.StringUtils;
@Override
protected boolean check() {
// If we can get the class, it means we have access to it
- Config.ALPHA_8;
+ Config c = Config.ALPHA_8;
return true;
}
}
// Some formats are not reliable
- // Second change: PNG
+ // Second chance: PNG
if (!ok && !format.equals("png")) {
ok = image.compress(Bitmap.CompressFormat.PNG, 90, fos);
}
try {
Bitmap image = BitmapFactory.decodeStream(stream);
if (image == null) {
+ String extra = "";
+ if (img.getSize() <= 2048) {
+ try {
+ extra = ", content: "
+ + new String(img.getData(), "UTF-8");
+ } catch (Exception e) {
+ extra = ", content unavailable";
+ }
+ }
String ssize = StringUtils.formatNumber(img.getSize());
throw new IOException(
- "Failed to convert input to image, size was: " + ssize);
+ "Failed to convert input to image, size was: " + ssize
+ + extra);
}
+
+ return image;
} finally {
stream.close();
}
-
- return image;
}
}