Imagesharp: Image.Load() with ''CRC Error. PNG Image chunk is corrupt"

Created on 13 Jul 2017  路  6Comments  路  Source: SixLabors/ImageSharp

Prerequisites

  • [X] I have written a descriptive issue title
  • [X] 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
  • [X] I have searched open and closed issues to ensure it has not already been reported

Description


I try to load PNG image that displays normally. It also loads normally with .NET Framework's System.Drawing.Image.FromFile().
There was similar issue that has been closed: #127

Steps to Reproduce

Simple code:

Image.Load("banner.png");

With image banner.zip cause an ImageSharp.ImageFormatException with stacktrace:

   at ImageSharp.Formats.PngDecoderCore.ReadChunkCrc(PngChunk chunk)
   at ImageSharp.Formats.PngDecoderCore.ReadChunk()
   at ImageSharp.Formats.PngDecoderCore.Decode[TPixel](Stream stream)
   at ImageSharp.Image.Decode[TPixel](Stream stream, Configuration config)
   at ImageSharp.Image.WithSeekableStream[T](Stream stream, Func`2 action)
   at ImageSharp.Image.Load[TPixel](Configuration config, Stream stream, IImageFormat& format)
   at ImageSharp.Image.Load[TPixel](Configuration config, String path)
   at ImageSharp.Image.Load(String path)
   at ImageSharpTest.Program.Main(String[] args) in c:\users\user
\documents\visual studio 2017\Projects\ImageSharpTest\Program.cs:line 12

System Configuration

  • ImageSharp version: 1.0.0-alpha9-00171
  • Environment: Windows 10 Enterprise Version 1703 Build 15063.483
  • Visual Studio Professional 2017 Version 15.2 (26430.15)
  • dotnet --info output:
.NET Command Line Tools (1.0.4)

Product Information:
 Version:            1.0.4
 Commit SHA-1 hash:  af1e6684fd

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.15063
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\1.0.4

Most helpful comment

Hi guys, got the same issue. Here's another image that fails. TweakPng has no issues reading the file as well as System.Drawing.

zincartabstract_smallbar.zip

Hope it helps.

All 6 comments

Just did a quick test to see if the image was actually corrupt. ImageMagick can read it without any issues and ImageMagick normally is very strict about errors inside an image. Means this is most likely an issue inside the decoder.

Any updates on this?

None yet I'm afraid, we've not had the opportunity (sickness, time constraints etc). You'll see something here as soon as we do.

Hi guys, got the same issue. Here's another image that fails. TweakPng has no issues reading the file as well as System.Drawing.

zincartabstract_smallbar.zip

Hope it helps.

Thanks. Yeah images that break our decoder are always useful. I'll get stuck in asap. Stuck doing stuff for my day job just now.

I've checked everything and the new fix works. Enjoy!

Was this page helpful?
0 / 5 - 0 ratings