Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

300dpi tiff image changed to 96pi jpg but pixel does not chage #206

Closed
liuyi520123 opened this issue Feb 26, 2023 · 1 comment
Closed

300dpi tiff image changed to 96pi jpg but pixel does not chage #206

liuyi520123 opened this issue Feb 26, 2023 · 1 comment

Comments

@liuyi520123
Copy link

liuyi520123 commented Feb 26, 2023

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

  • OS vendor and version:
    windows 11
  • JDK vendor and version:
    1.8.0_40
  • Thumbnailator version:
    0.4.19
  • Test file:
    2211180344517.zip
@coobird
Copy link
Owner

coobird commented Sep 16, 2023

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.

@coobird coobird closed this as completed Sep 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants