-
-
Notifications
You must be signed in to change notification settings - Fork 323
Description
Describe the bug
When reading and then writing a 32-bit per channel grayscale TIFF image in linear colorspace, the written colors are brightened.
Version information
-
The version of the TwelveMonkeys ImageIO library in use.
imageio-tiff:3.12.0 -
The exact output of
java --version(orjava -versionfor older Java releases).
openjdk 23 2024-09-17
OpenJDK Runtime Environment (build 23+37-2369)
OpenJDK 64-Bit Server VM (build 23+37-2369, mixed mode, sharing)
- Extra information about OS version, server version, standalone program or web application packaging, executable wrapper, etc. Please state exact version numbers where applicable.
This is on a Linux Mint 21.3 desktop, running directly from a jar.
To Reproduce
Steps to reproduce the behavior:
- Compile the below sample code
- Download the sample image file
- Run the code with the sample file
- See error
Expected behavior
The output image is a 32-bit per channel integer grayscale image in linear colorspace with the same shade of grey as the input.
Example code
System.out.println("Is headless? " + System.getProperty("java.awt.headless"));
var image = ImageIO.read(new File("./Untitled_32bit.tif"));
System.out.println("Width: " + image.getWidth());
System.out.println("Height: " + image.getHeight());
System.out.println("Color model: " + image.getColorModel().toString());
System.out.println("Color space is sRGB: " + image.getColorModel().getColorSpace().isCS_sRGB());
System.out.println("Channels: " + image.getColorModel().getColorSpace().getNumComponents());
System.out.println("Channel size: " + image.getColorModel().getComponentSize()[0]);
var writer = ImageIO.getImageWritersBySuffix("tif").next();
var params = writer.getDefaultWriteParam();
params.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
params.setCompressionType("Deflate");
writer.setOutput(ImageIO.createImageOutputStream(new File("./out.tif")));
writer.write(image);
Sample file(s)
Attach any sample files needed to reproduce the problem. Use a ZIP-file if the format is not directly supported by GitHub.
Stak trace
No stack trace.
Screenshots
PNG of input image (totally different encoding, just for visual demo):
PNG of output image:

