Closed liuyi520123 closed 10 months ago
Sorry for overlooking this issue.
The dots-per-inch (DPI) information is metadata that's kept in certain file formats to instruct how an image should be printed. It doesn't actually affect the contents of the image file itself (i.e., the pixels.)
As Thumbnailator deals with the dimensions in pixels only, setting the scaling to 1x (i.e. .scale(1f)
) will end up with the same number of pixels before and after the transformation. This is intended behavior.
Expected behavior
300dpi tiff image when change to jpg keep dpi and pixel
Actual behavior
tiff dpi=300dpi pixel=1181 x 1181 image convert to jpg dpi=96dpi pixel=1181 x 1181
Steps to reproduce the behavior
BufferedImage tif = ImageIO.read(new File("D:\\868602602.tif")); Thumbnails .of(tif) .outputFormat("jpg") .scale(1f) .outputQuality(1f) .toFile(new File("D:\\868602602.jpg"));
Environment