SixLabors / ImageSharp

:camera: A modern, cross-platform, 2D Graphics library for .NET
https://sixlabors.com/products/imagesharp/
Other
7.34k stars 847 forks source link

The number of samples in the TIFF BitsPerSample entry is not supported. #2587

Closed kandeepandev closed 9 months ago

kandeepandev commented 9 months ago

Prerequisites

ImageSharp version

3.0.2

Other ImageSharp packages and versions

3.0.1

Environment (Operating system, version and so on)

aks and windows 2010

.NET Framework version

6

Description

We are using Image sharp to convert the tiff images to png, as part of that process we are using below code but it is throwing the error for for specific tiff files but file looks vaild tiff images only.

When try to load tiff images using the below code through the error "The number of samples in the TIFF BitsPerSample entry is not supported."

using (MemoryStream loadImage = new MemoryStream(byteArray)) { image = Image.Load(loadImage); }

So can you suggest the possible fix or work around for this issue. I am login the issue as behalf of RM and RM have a license for this library.

Steps to Reproduce

  1. Use the attached sample tiff images.
  2. Use the below code to load the tiff images using (MemoryStream loadImage = new MemoryStream(byteArray)) { image = Image.Load(loadImage); }

Images

SampleTiffs.zip

brianpopow commented 9 months ago

The Bits/Sample is missing in these images, it should be 1. @JimBobSquarePants How do you think we should handle this? Should we assume Bits/Sample is 1, when its missing and compression is CCITT Group 4?

tiffinfo:

=== TIFF directory 0 ===
TIFF Directory at offset 0x1561c (87580)
  Image Width: 2446 Image Length: 3453
  Resolution: 300, 300 pixels/inch
  Compression Scheme: CCITT Group 4
  Photometric Interpretation: min-is-white
  Rows/Strip: 1716
  Planar Configuration: single image plane
JimBobSquarePants commented 9 months ago

@brianpopow Yes, I think so. The compression format normally only used on bitonal images so that seems a sensible default.

brianpopow commented 9 months ago

@JimBobSquarePants ok, I will prepare a fix for that.

@kandeepandev Do we have the permission to use your sample images for unit tests?

kandeepandev commented 9 months ago

Ya, we can use that.

Thanks, Kandeepan

On Fri, Nov 24, 2023, 11:13 PM Brian Popow @.***> wrote:

@JimBobSquarePants https://github.com/JimBobSquarePants ok, I will prepare a fix for that.

@kandeepandev https://github.com/kandeepandev Do we have the permission to use your sample images for unit tests?

— Reply to this email directly, view it on GitHub https://github.com/SixLabors/ImageSharp/issues/2587#issuecomment-1825954239, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEFZH5RQRX2TVO6YWKACWK3YGDMDZAVCNFSM6AAAAAA7XT6W36VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRVHE2TIMRTHE . You are receiving this because you were mentioned.Message ID: @.***>

kandeepandev commented 9 months ago

Hi team, Thank you for the quick fix. When it will be available as release?

Thanks, Kandeepan

On Sat, Nov 25, 2023, 11:18 AM James Jackson-South @.***> wrote:

Closed #2587 https://github.com/SixLabors/ImageSharp/issues/2587 as completed via #2590 https://github.com/SixLabors/ImageSharp/pull/2590.

— Reply to this email directly, view it on GitHub https://github.com/SixLabors/ImageSharp/issues/2587#event-11060122701, or unsubscribe https://github.com/notifications/unsubscribe-auth/BEFZH5RIODD4AEI2K2PW5Q3YGGBCDAVCNFSM6AAAAAA7XT6W36VHI2DSMVQWIX3LMV45UABCJFZXG5LFIV3GK3TUJZXXI2LGNFRWC5DJN5XDWMJRGA3DAMJSGI3TAMI . You are receiving this because you were mentioned.Message ID: @.***>

JimBobSquarePants commented 9 months ago

The nightlies already are, see the readme for details