image-rs / image

Encoding and decoding images in Rust
Apache License 2.0
4.89k stars 606 forks source link

`save` method result's in a all white 100% transparent image #1867

Open jkoking opened 1 year ago

jkoking commented 1 year ago

Expected

DynamicImage is saved to the file system.

Actual behaviour

save's a all white 100% transparent image to the file system.

Reproduction steps

https://github.com/jkoking/image-rs-issue-1867

My original discussions post

1865

fintelia commented 1 year ago

It seems that we're producing corrupt TIFFs and the color type is Rgba8 so not even anything exotic:

$ tiffinfo ocr.tiff
TIFFReadDirectory: Warning, Sum of Photometric type-related color channels and ExtraSamples doesn't match SamplesPerPixel. Defining non-color channels as ExtraSamples..
=== TIFF directory 0 ===
TIFF Directory at offset 0x1fa4130 (33177904)
  Image Width: 3840 Image Length: 2160
  Resolution: 1, 1 (unitless)
  Bits/Sample: 8
  Sample Format: unsigned integer
  Compression Scheme: None
  Photometric Interpretation: RGB color
  Samples/Pixel: 4
  Rows/Strip: 66
  Planar Configuration: single image plane

@jkoking If you are just looking for a workaround, either removing the alpha channel (img.to_rgb8().save("ocr.tiff")) or picking a different file format (img.save("ocr.png")) should work. However, this case really should be fixed...