import be.nikiroo.utils.Image;
import be.nikiroo.utils.ImageUtils;
+import be.nikiroo.utils.StringUtils;
/**
* This class offer some utilities based around images and uses java.awt.
public class ImageUtilsAwt extends ImageUtils {
@Override
protected boolean check() {
- // If we can get the class, it means we have access to it
- @SuppressWarnings("unused")
- Object test = ImageIO.class;
+ // Will not work if ImageIO is not available
+ ImageIO.getCacheDirectory();
return true;
}
}
if (image == null) {
- throw new IOException("Failed to convert input to image");
+ 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
+ + extra);
}
// Note: this code has been found on Internet;