Repository navigation
Closed
Labels
Description
Prerequisites
- I have bought a Commercial License
- 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
DEBUGandRELEASEmode - I have searched open and closed issues to ensure it has not already been reported
ImageSharp version
3.0.1
Other ImageSharp packages and versions
No
Environment (Operating system, version and so on)
Linux
.NET Framework version
NET 6
Description
When loading some Tiffs, we received this exception.
I found a similar closed issue, but it seemed different to me.
The closed issue related a encode problem. Here it's a decode problem.
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SixLabors.ImageSharp.Formats.Tiff.TiffDecoderCore.DecodeTilesChunky[TPixel](ImageFrame`1 frame, Int32 tileWidth, Int32 tileLength, Int32 tilesAcross, Int32 tilesDown, Span`1 tileOffsets, Span`1 tileByteCounts, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.Tiff.TiffDecoderCore.DecodeImageWithTiles[TPixel](ExifProfile tags, ImageFrame`1 frame, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.Tiff.TiffDecoderCore.DecodeFrame[TPixel](ExifProfile tags, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.Tiff.TiffDecoderCore.Decode[TPixel](BufferedReadStream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream, Func`3 largeImageExceptionFactory, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.ImageDecoderUtilities.Decode[TPixel](IImageDecoderInternals decoder, Configuration configuration, Stream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.Tiff.TiffDecoder.Decode[TPixel](DecoderOptions options, Stream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.Tiff.TiffDecoder.Decode(DecoderOptions options, Stream stream, CancellationToken cancellationToken)
at SixLabors.ImageSharp.Formats.ImageDecoder.<>c__DisplayClass1_0.<Decode>b__0(Stream s)
at SixLabors.ImageSharp.Formats.ImageDecoder.<WithSeekableStream>g__PeformActionAndResetPosition|11_0[T](Stream s, Int64 position, <>c__DisplayClass11_0`1& )
at SixLabors.ImageSharp.Formats.ImageDecoder.WithSeekableStream[T](DecoderOptions options, Stream stream, Func`2 action)
at SixLabors.ImageSharp.Formats.ImageDecoder.Decode(DecoderOptions options, Stream stream)
at SixLabors.ImageSharp.Image.Decode(DecoderOptions options, Stream stream)
at SixLabors.ImageSharp.Image.<>c__DisplayClass80_0.<Load>b__0(Stream s)
at SixLabors.ImageSharp.Image.WithSeekableStream[T](DecoderOptions options, Stream stream, Func`2 action)
at SixLabors.ImageSharp.Image.Load(DecoderOptions options, Stream stream)
at SixLabors.ImageSharp.Image.Load(Stream stream)
Steps to Reproduce
Load the provided images from a stream.
The error throws at Image.Load command.
public static MemoryStream ConverterPara(MemoryStream imagemStream)
{
var pngEncoder = new PngEncoder()
{
FilterMethod = PngFilterMethod.Adaptive,
CompressionLevel = PngCompressionLevel.BestCompression,
TransparentColorMode = PngTransparentColorMode.Clear,
ColorType = PngColorType.Grayscale,
BitDepth = PngBitDepth.Bit4,
SkipMetadata = true
};
imagemStream.Position = 0;
var resultadoStream = new MemoryStream();
using (var imagem = Image.Load(imagemStream))
{
using (var clone = imagem.CloneAs<L8>())
clone.Save(resultadoStream, pngEncoder);
}
return resultadoStream;
}
Images
Reacted by James Jackson-South
Activity
JimBobSquarePants commentedon Apr 12, 2023
Thanks for the images. Will have a look asap.
brianpopow commentedon Apr 12, 2023
Both images have none standard tile width according to
tiffinfojoaovsoares commentedon Apr 12, 2023
I don't really know what it means. Those images are invalid?
I mean, both could be opened by other softwares.
What I need to do?
BTW: thanks for the answer.
brianpopow commentedon Apr 12, 2023
I still try to figure this out. My comment was more addressed towards @JimBobSquarePants who also wanted to figure this out (sorry for not being explicit here). I thought this may help debugging the issue. If other software/viewers can open it, we should also try to be able to decode it.
brianpopow commentedon Apr 13, 2023
I think that I found the issue.
@joaovsoares would it be ok for you, if I use the provided test images in a unit test?I was able to create a similar test image.
PR for the fix is open.
Fix retrieving wrong tile height, fixes #2435
Add test for #2435
joaovsoares commentedon Apr 13, 2023
@brianpopow sure!
Sorry for the delayed answer.