Skip to content

Interlacing is not supported #9

Closed

Description

@JimBobSquarePants

From @Bartmax on May 6, 2016 4:25

When using a Png file I get this error:

ImageProcessorCore.ImageFormatException: Interlacing is not supported

some png works but some doesn't.

The code is here:
https://github.com/JimBobSquarePants/ImageProcessor/blob/abbf63f863635d4df1a04d322eccd425db7e82db/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs#L385

What does this mean? is this a limitation of the library or am I doing something wrong or a bug?

Copied from original issue: JimBobSquarePants/ImageProcessor#379

Activity

  1. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    Hi @Bartmax

    It means exactly that. Png files can be interlaced but it is strongly recommended not to do that as it hurts compression, increasing filesize.

    See

    Interlaced png files are generally uncommon so I haven't gone out of my way to support them cos it's complex. I could maybe add support in the future though as there is good reference material to base my code on so if you could share a failing image that would be really useful.

  2. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    From @Bartmax on May 6, 2016 4:39

    Thanks for the fast reply.

    Here is a sample file that is failing. I have 3 out of 10 that seems to be interlaced :(

    546ce378-2bcf-4604-8338-91d9065727c4

  3. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    No worries. I'll branch off and try to tinker with it. Fingers crossed it's not too difficult.

  4. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    This is tricky stuff...

    I've been looking at the spec and also the Golang implementation.

    https://www.w3.org/TR/PNG/
    https://golang.org/src/image/png/reader.go

    Reading up it looks like I need to decode each scanline 8 times which will require some significant refactoring here.

    https://github.com/JimBobSquarePants/ImageProcessor/blob/7d28a87716e4b7c2dea73bc0fb804873d30372f6/src/ImageProcessorCore/Formats/Png/PngDecoderCore.cs#L242

    I could really do with someone who has done this before stepping up and adding the code.

  5. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    From @MarcosMeli on August 29, 2016 16:28

    @JimBobSquarePants
    Just a little question here. There is an option to use the .Net native image load implementation and convert the resulting Bitmap to the format you need ?

    ie. try to use custom decode for the pngs but, if interlaced, so use Bitmap constructor: https://msdn.microsoft.com/en-us/library/z7ha67kw(v=vs.110).aspx

    Thanks

  6. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    From @dlemstra on August 29, 2016 16:59

    The library should build on .NET Core where we don't have the Image class of System.Drawing. Adding it to the encoder should be the way to go.

  7. JimBobSquarePants commented on Oct 30, 2016

    @JimBobSquarePants
    MemberAuthor

    From @MarcosMeli on August 29, 2016 17:50

    @dlemstra Thanks for clarification, I understand now.

  8. JimBobSquarePants commented on Dec 3, 2016

    @JimBobSquarePants
    MemberAuthor

    Had a crack at this and I'm so close. I'm reading the stream fine without error but something isn't right after. It looks like my offset calculation is wrong. Could someone have a look?

    splash-interlaced

  9. JimBobSquarePants commented on Dec 4, 2016

    @JimBobSquarePants
    MemberAuthor

    Ok @Bartmax so I'm almost there with this.

    I can decode your rgb image perfectly now and my rgba image also. I have one test image though (rgb 8x8) that is showing a two pixel error and I don't know why. If anyone reading could have a look that would be great.

    Here's your image decoded then encoded in non-interlaced mode.

    interlace-2

  10. Bartmax commented on Dec 4, 2016

    @Bartmax

    So the only problem is with rgb 8x8 image ? Can you point me to the code? is there a failing test? I have no experience on image manipulation but I will be glad to help and try to solve this. Maybe we can take the converstaion offline to slack so you can guide me in how to approach the problem?

  11. Bartmax commented on Dec 4, 2016

    @Bartmax

    played with the code, I see some errors (or I think are errors) on the tests, see:

    I have no idea if this has or not anything to do with the interlace thing and need some guidance on how to test if it works with your interlaced.png (rgba 8x8) file.

  12. added a commit that references this issue on Dec 4, 2016
    679c0e3
  13. JimBobSquarePants commented on Dec 4, 2016

    @JimBobSquarePants
    MemberAuthor

    Thanks for highlighting the failing tests, not sure how that slipped through but they are unrelated. I've fixed them in my branch.

    I managed to fix the decoder! Turns out I wasn't clearing an array at the correct time.

  14. Bartmax commented on Dec 4, 2016

    @Bartmax

    @JimBobSquarePants well excellent news!! hope to be more useful next time 😄

  15. JimBobSquarePants commented on Dec 4, 2016

    @JimBobSquarePants
    MemberAuthor

    Don't worry, you were useful 👍

    I've merged my branch and you should see a shiny new working build now.

  16. added a commit that references this issue on Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions