Description
Operating System:
- Ubuntu
Libvips Version:
- Libvips 8.15 with OpenSlide 4.0
Slide Format:
- DICOM, TIFF
Issue Details:
I am using pyvips to load a slide (A) and save it as a JPEG-compressed TIFF (B). When I use tiffsave with the default Q factor (75), I can correctly load slide (B) with OpenSlide. However, if I change the Q factor value, OpenSlide displays the YCbCr channels instead of RGB.
This issue occurs with slide (A) in both DICOM and TIFF formats.
For slides in TIFF format, the issue arises when loading with pyvips.Image.new_from_file or pyvips.Image.openslideload, but not with vips.Image.tiffload.
The problem in my case is that I want to load a DICOM and save it to TIFF.
Using tifftools to inspect slide (B)'s metadata, I found that the TIFF TAG PhotometricInterpretation (262) is set to 2 (RGB) for problematic slides and 6 (YCbCr) for slides that are read correctly. It appears that OpenSlide is not converting to RGB due to this metadata.
Manually changing this value allows OpenSlide to read the slide correctly, although the following warning is still generated:
OpenSlide Warning:
JPEGFixupTagsSubsamplingSec: Warning, Auto-corrected former TIFF subsampling values [2,2] to match subsampling values inside JPEG compressed data [1,1].