You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Description
Try loading the attached image and see that it generates a 'Bad compression method for ZLIB header: cmf=237' error. System.Drawing can open this image.
Steps to Reproduce
Image.Load(File.OpenRead("1.png"))
System Configuration
.NET Standard 2.0 Dll hosted in a .NET Framework 4.6.1 windows service
ImageSharp version: 1.0.0-beta0002
Other ImageSharp packages and versions: Sizlabors.Core 1.0.0-beta0004
Environment (Operating system, version and so on): Windows 10
Theoretically it looks like we could potentially handle these changes with some updates to our decoder based on the following, it looks like a lot of work though for all our different color types:
seeing as chrome doesn't seem to even seem to render it then i'm inclined to think we should defiantly push it past v1 and even then see how much of an issue its causing in the future and make a another call then.
Ha! Doesn't it! I only have Edge installed at the mo cos I had to get my laptop replaced. That renders something but it ain't pretty. Yeah let's leave it for now then.
Ok, have moved it to futures. Gonna do a little cleanup in the png decoder around the zlib headers to remove an allocation I saw that we don't need anyway.
I would detect this specific format, but just to throw a more specific exception, like "malformed iPhone PNG detected", I think it's Apple's responsability to write proper PNGs, not the responsability of others to read their malformed files.
changed the title [-]Image.Load<Rgba32> Results in 'Bad compression method for ZLIB header: cmf=237' Exception[/-][+]Decoding malformed iPhone generated PNG throws 'Bad compression method for ZLIB header: cmf=237'[/+]on May 26, 2018
Activity
JimBobSquarePants commentedon Dec 23, 2017
Hi @zeus82
Thanks for the detail and the input image. It turns out that image is not a valid png.
http://iphonedevwiki.net/index.php/CgBI_file_format
There's quite a few differences between the format
@antonfirsov @tocsoft @dlemstra
Theoretically it looks like we could potentially handle these changes with some updates to our decoder based on the following, it looks like a lot of work though for all our different color types:
http://www.axelbrz.com.ar/?mod=iphone-png-images-normalizer
I don't know if we should attempt this for V1 though. What do you think?
tocsoft commentedon Dec 23, 2017
seeing as chrome doesn't seem to even seem to render it then i'm inclined to think we should defiantly push it past v1 and even then see how much of an issue its causing in the future and make a another call then.
JimBobSquarePants commentedon Dec 23, 2017
Ha! Doesn't it! I only have Edge installed at the mo cos I had to get my laptop replaced. That renders something but it ain't pretty. Yeah let's leave it for now then.
antonfirsov commentedon Dec 23, 2017
Only Windows + GDI based decoders seem do decode it properly. I consider this issue as low-priority one, definitely not a show-stopper for V 1.0.
JimBobSquarePants commentedon Dec 24, 2017
Ok, have moved it to futures. Gonna do a little cleanup in the png decoder around the zlib headers to remove an allocation I saw that we don't need anyway.
vpenades commentedon Jan 3, 2018
I would detect this specific format, but just to throw a more specific exception, like "malformed iPhone PNG detected", I think it's Apple's responsability to write proper PNGs, not the responsability of others to read their malformed files.
[-]Image.Load<Rgba32> Results in 'Bad compression method for ZLIB header: cmf=237' Exception[/-][+]Decoding malformed iPhone generated PNG throws 'Bad compression method for ZLIB header: cmf=237'[/+]qmfrederik commentedon Jun 13, 2018
These files have been processed with an Apple-variation of pngcrush.
You can use PNGDecrush (source) to decrush the image, which can then be fed to other image libraries.
E.g.:
JimBobSquarePants commentedon Jun 13, 2018
@qmfrederik Thanks for the input; that a really useful tool! 👍
I'm going to get around to natively handling this one day, need to do some cleanup of the decoder first though.
Throw exception when malformed apple png chunk is detected (#410)