You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My code is as follows
public static void main(String[] args) throws Exception {
String srcFile = "C:\Users\admin\Desktop\2222.png";
String desFile = "C:\data1\share\biztable\mini\task_fill\333.png";
BufferedImage originalImage = ImageIO.read(new File(srcFile));
BufferedImage thumbnail = Thumbnails.of(originalImage)
.size(200, 200)
.keepAspectRatio(false)
.asBufferedImage();
Thumbnails.of(thumbnail)
.scale(0.3)
.outputQuality(0.25f)
.toFile(desFile);
}
The abnormal information is as follows
Exception in thread "main" javax.imageio.IIOException: Unsupported Image Type
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1079)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1050)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
at javax.imageio.ImageIO.read(ImageIO.java:1308)
at zsoft.gov.datacenter.biztable.common.utils.UploadUtil.main(UploadUtil.java:266)
May I ask what causes it? Or is the thumbnailator not supported?
The text was updated successfully, but these errors were encountered:
And inspecting closer, Java thinks it's a JPEG file even though it has a PNG extension. Therefore, it seems like your image file is mislabeled with a wrong extension. This is not an issue with Thumbnailator as it's not being invoked.
Why do png thumbnails report exceptions?
public static void main(String[] args) throws Exception {
String srcFile = "C:\Users\admin\Desktop\2222.png";
String desFile = "C:\data1\share\biztable\mini\task_fill\333.png";
BufferedImage originalImage = ImageIO.read(new File(srcFile));
BufferedImage thumbnail = Thumbnails.of(originalImage)
.size(200, 200)
.keepAspectRatio(false)
.asBufferedImage();
Thumbnails.of(thumbnail)
.scale(0.3)
.outputQuality(0.25f)
.toFile(desFile);
}
Exception in thread "main" javax.imageio.IIOException: Unsupported Image Type
at com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1079)
at com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1050)
at javax.imageio.ImageIO.read(ImageIO.java:1448)
at javax.imageio.ImageIO.read(ImageIO.java:1308)
at zsoft.gov.datacenter.biztable.common.utils.UploadUtil.main(UploadUtil.java:266)
May I ask what causes it? Or is the thumbnailator not supported?
The text was updated successfully, but these errors were encountered: