Skip to content

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

Description

@kandeepandev

Prerequisites

  • I have written a descriptive issue title
  • I have verified that I am running the latest version of ImageSharp
  • I have verified if the problem exist in both DEBUG and RELEASE mode
  • I have searched open and closed issues to ensure it has not already been reported

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

Activity

  1. brianpopow commented on Nov 24, 2023

    @brianpopow
    Collaborator

    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
    
  2. JimBobSquarePants commented on Nov 24, 2023

    @JimBobSquarePants
    Member

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

  3. brianpopow commented on Nov 24, 2023

    @brianpopow
    Collaborator

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

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

  4. kandeepandev commented on Nov 24, 2023

    @kandeepandev
    Author
  5. self-assigned this
    on Nov 24, 2023
  6. added a commit that references this issue on Nov 24, 2023
    b46ab5a
  7. kandeepandev commented on Nov 29, 2023

    @kandeepandev
    Author
  8. JimBobSquarePants commented on Nov 29, 2023

    @JimBobSquarePants
    Member

    The nightlies already are, see the readme for details

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions