Closed sunweihxh closed 3 years ago
Good day @sunweihxh!
You should post:
Most probably your image either has an unsupported format or is broken. AFAIR I had some exceptions on jpeg files that have broken EXIF info or something alike. I re-saved it with a graphic editor, after it the thumbnailator worked. For HEIC files, I converted it to JPEG.
net.coobird.thumbnailator.tasks.UnsupportedFormatException: No suitable ImageReader found for d:\images\image\courseUserWork\2020-10-15\xIVSkZlYEeGYhpNuokqG\original. at net.coobird.thumbnailator.tasks.io.FileImageSource.read(FileImageSource.java:118) at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(SourceSinkThumbnailTask.java:76) at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Thumbnailator.java:53) at net.coobird.thumbnailator.Thumbnails$Builder.toOutputStream(Thumbnails.java:2737)
@sunweihxh The file you uploaded is a WebP image. (Despite the "jpg" extension it wasn't a JPEG.)
Thumbnailator relies on the Java Image I/O API's image reading and writing facilities, which does not have support for WebP out-of-the-box. In order to use WebP, you'll need to find a compatible Image I/O plugin.
There appears to be some options for using WebP from Java Image I/O which you'll be able to find in a previously filed issue (#137) and in a comment I made here.
Once such a plugin is enabled, you should be able to use Thumbnailator without further modifications.
@coobird @dmitry-weirdo thanks a lot.
Expected behavior
got a exception:net.coobird.thumbnailator.tasks.UnsupportedFormatException: No suitable ImageReader found
Steps to reproduce the behavior
scale0_3 = new File(imagePath+File.separator+"scale0_3");
Environment
jdk1.8 tomcat8.5