coobird / thumbnailator

Thumbnailator - a thumbnail generation library for Java
MIT License
5.16k stars 786 forks source link

the compressed image is abnormal #191

Closed Herewell closed 2 years ago

Herewell commented 2 years ago

hi, I found a problem as follows: When I use the code below to compress the image,The compressed image is abnormal。

        Thumbnails.of(file)
                .size(640, 640)
                .keepAspectRatio(false)
                .toFile(resizeFile);

You can find the images before and after compression in the attachment。 How should i solve this problem,please help me

Environment JDK1.8 and thumbnailator's version is 0.4.8 after: after before: before

coobird commented 2 years ago

This is a problem with Java's default JPEG reader not reading the JPEG properly.

You'll likely get better results if you use TwelveMonkey ImageIO's JPEG reader instead; you'll just need to include it as a Maven dependency and as long as it's in the classpath, that JPEG reader will be used instead of the default JPEG reader.

Herewell commented 2 years ago

it‘s ok,thanks!