thumbnailator
thumbnailator copied to clipboard
javax.imageio.IIOException: Invalid JPEG file structure: two SOF markers
Expected behavior
Image being resized, recompressed
Actual behavior
An exception is raised : javax.imageio.IIOException: Invalid JPEG file structure: two SOF markers for a particular photo, success with all previous ones. The original photo is here couldn't upload it as its size is over 10Mb (26Mb).
The photo can be loaded with various software :
- geeqie => no error returned
- chrome => no error returned
- gimp => a warning is shown :
scala> {
| Thumbnails
| .of(input)
| .useExifOrientation(true)
| .size(1920, 1920)
| .keepAspectRatio(true)
| .outputQuality(0.8)
| .allowOverwrite(false)
| .toFile(output)
| }
javax.imageio.IIOException: Unsupported marker type 0x7a
at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readImage(Native Method)
at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.readInternal(JPEGImageReader.java:1382)
at java.desktop/com.sun.imageio.plugins.jpeg.JPEGImageReader.read(JPEGImageReader.java:1162)
at net.coobird.thumbnailator.tasks.io.InputStreamImageSource.readImage(Unknown Source)
at net.coobird.thumbnailator.tasks.io.InputStreamImageSource.read(Unknown Source)
at net.coobird.thumbnailator.tasks.io.FileImageSource.read(Unknown Source)
at net.coobird.thumbnailator.tasks.SourceSinkThumbnailTask.read(Unknown Source)
at net.coobird.thumbnailator.Thumbnailator.createThumbnail(Unknown Source)
at net.coobird.thumbnailator.Thumbnails$Builder.toFile(Unknown Source)
... 66 elided
Steps to reproduce the behavior
Thumbnails
.of(input)
.useExifOrientation(true)
.size(1920, 1920)
.keepAspectRatio(true)
.outputQuality(0.8)
.allowOverwrite(false)
.toFile(output)
Environment
- OS vendor and version: Linux Mint 21 Vanessa -
Kernel 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux - JDK vendor and version: OpenJDK 17.0.8 2023-07-18
- Thumbnailator version: 0.4.20
Found this hint : https://stackoverflow.com/questions/31094267/invalid-jpeg-file-structure-two-soi-markers-error