Skip to content

ImageSharp sometimes add gray rectangle at the bottom right  #2638

Description

@laitauchocolat

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.1.0

Other ImageSharp packages and versions

3.0.1

Environment (Operating system, version and so on)

Windows 11

.NET Framework version

.NET 6

Description

On some picture, ImageSharp will add a gray rectangle at the bottom right,
Original: 826862_3
Final: square

Steps to Reproduce

Download sample projet c#
Replace fb.jpg with the original picture:
826862_3
try it with version 3.0.1, (no gray square)
erease debug + obj and install the latest version 3.1.2 and execute, (gray square)

Images

No response

Activity

  1. JimBobSquarePants commented on Jan 15, 2024

    @JimBobSquarePants
    Member

    @br3aker would it be possible for you to have a look at this? I thought we’d fixed it previously.

  2. omuleanu commented on Jan 29, 2024

    @omuleanu

    I got the same thing net8.0
    mango
    mangoSaved

    I save it like this:

    using var fstream = file.OpenReadStream(); // file is IFormFile (asp.net core)
    
    var img = Image.Load(fstream);
    await img.SaveAsync(filePath, new JpegEncoder { Quality = 50 });
    

    cropping the bottom part helps avoid the problem

  3. JimBobSquarePants commented on Jan 30, 2024

    @JimBobSquarePants
    Member

    Does the issue happen on decode or encode?

    I got the same thing net8.0

    What do you mean by this? Same version different target framework?

  4. omuleanu commented on Jan 30, 2024

    @omuleanu

    @JimBobSquarePants
    version 3.1.2
    net8.0
    the image with the gray square is the result of img.SaveAsync(filePath, new JpegEncoder { Quality = 50 });
    I assume this is encode.

  5. JimBobSquarePants commented on Jan 30, 2024

    @JimBobSquarePants
    Member

    OK. Can you please encode the image as Png and let me know whether the result is the same?

  6. omuleanu commented on Jan 30, 2024

    @omuleanu

    using await img.SaveAsPngAsync(Path.ChangeExtension(filePath, "png")); I also get the gray square,
    I'm also doing a clone and resize to 300x300 and that one also has the square.

    2

  7. JimBobSquarePants commented on Jan 30, 2024

    @JimBobSquarePants
    Member

    Decoder then. Will need to figure out the commit that broke it.

  8. br3aker commented on Feb 1, 2024

    @br3aker
    Contributor

    Hm, that's strange. I'll take a look this weekend.

  9. br3aker commented on Feb 26, 2024

    @br3aker
    Contributor

    Thanks @br3aker it was likely something around this. #2516 (files)

    That's actually it but fix is rather complex if we don't want to break existing logic with that fast 'DOS images'. Working on it atm.

  10. JimBobSquarePants commented on Feb 26, 2024

    @JimBobSquarePants
    Member

    @br3aker I kid you not I was JUST this second writing a comment to see if you wanted me to have a look. 🤪

    Thanks for helping out. Much appreciated!

  11. phoebusryan commented on Mar 6, 2024

    @phoebusryan

    This also happens in Version 2.1.6. It's not an Version 3-Issue

  12. hightechie commented on Mar 7, 2024

    @hightechie

    This also happens in Version 2.1.6. It's not an Version 3-Issue

    I upgraded from 2.1.3 to 2.1.7 due to CVE-2024-27929 and am seeing the gray rectangle on certain images also.

  13. JimBobSquarePants commented on Mar 7, 2024

    @JimBobSquarePants
    Member

    The same code is in both v2 and v3. Trust @br3aker in his analysis, he knows more about that decoder than anyone on the planet.

  14. 7 remaining items

  15. JimBobSquarePants commented on Mar 27, 2024

    @JimBobSquarePants
    Member

    Working on it! Just gotta get one critical task done first.

  16. hightechie commented on Apr 19, 2024

    @hightechie

    @JimBobSquarePants - Is there any chance of this being backported to v2? (we're still dependent on .NET Standard) I just tried upgrading to 2.8 from 2.3 (to address the two CVE's) and the gray rectangle appears with our test images. Thank you kindly if you're able to make this happen.

  17. JimBobSquarePants commented on Apr 19, 2024

    @JimBobSquarePants
    Member

    If you open a PR against our 2.1.x release branch I can get one merged. We’re only backporting security releases in-house at the moment to stay on top of maintenance.

  18. hightechie commented on Apr 19, 2024

    @hightechie

    If you open a PR against our 2.1.x release branch I can get one merged. We’re only backporting security releases in-house at the moment to stay on top of maintenance.

    I appreciate the quick reply and certainly understand you have to prioritize your time. If I knew how to do this I absolutely would do so, I'm just not sure how to even go about attempting something like this unfortunately. Regardless, thank you for everything you do for the community here.

  19. fabercs commented on May 8, 2024

    @fabercs

    Hi, I got the same issue in my project .net6.0 and the ImageSharp version is 3.1.4.
    I couldn't figure out if this issue fixed in 3.1.4 or for next release, anyone help?

  20. JimBobSquarePants commented on May 10, 2024

    @JimBobSquarePants
    Member

    Hi, I got the same issue in my project .net6.0 and the ImageSharp version is 3.1.4. I couldn't figure out if this issue fixed in 3.1.4 or for next release, anyone help?

    The fix has been released. If you are still seeing an issue, please raise a separate ticket with the image in question.

  21. phoebusryan commented on Dec 20, 2024

    @phoebusryan

    It still does not work with 2.1.9 and .net Framework 4.6.2. Example images here:

    70922
    70968
    70973_2
    70974_2
    70977_2

  22. antonfirsov commented on Dec 21, 2024

    @antonfirsov
    Member

    2.1.* is unmaintained, only security-critical fixes are being backported.

  23. phoebusryan commented on Dec 23, 2024

    @phoebusryan

    So this issue will never fixed in 2.1.x? Unfortunately, we cannot use version 3 because we do not (yet) use .net core

  24. JimBobSquarePants commented on Dec 23, 2024

    @JimBobSquarePants
    Member

    If you open a PR against our 2.1.x release branch I can get one merged. We’re only backporting security releases in-house at the moment to stay on top of maintenance.

  25. added 3 commits that reference this issue on Jan 24, 2025
    4d5ca47
    bc7c600
    20260cd
  26. Visual-Vincent commented on Jan 24, 2025

    @Visual-Vincent
    Sponsor

    I have opened a pull request (#2868) that backports this to 2.1.x.

  27. Visual-Vincent commented on Mar 19, 2025

    @Visual-Vincent
    Sponsor

    The PR was finalized and merged by the maintainers - Thank you for the assistance!

    These changes have now been backported and released as part of v2.1.10.

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