• Hi,

    when I upload a png image and try to use the scale functions, the png image gets a black square.

    This problem has been asked before, but all topics are closed or resolved, but no specific solution is given.

    I already aksed my hoster to update GD Lib to the newset version, the problem still exists. Do yo know a working GD Lib vesion, where transparent png images work?

    WP 5.8
    PHP 7.4
    Easy Watermark 1.0.11

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Kuba Mikita

    (@kubitomakita)

    Hi @steffiiiii,

    sorry for the issue. The problem is very hard to catch, as there seem to be different problems with different usage cases and GD lib versions. Upgrading to the latest GD available for PHP 7.4 is the best shot we can advise.

    Because the problem is so fluid we decided to create a cloud image processor with which we can guarantee flawless image watermarking, but this, unfortunately, is not near the finish line yet.

    Thread Starter steffiiiii

    (@steffiiiii)

    Hi @kubitomakita,

    I did some more testing. On my localhost (PHP 7.4.12) it works as expected.
    But on two different live servers (PHP 7.4.19 and 7.4.23), it doesn’t.
    Do you know which specific versions of PHP and GD work best?

    Thanks

    Thread Starter steffiiiii

    (@steffiiiii)

    Hi @kubitomakita,

    I did some more testing and debugging and found a solution!

    I don’t know why, but the problem is your “is_alpha_png” function in AttachmentProcessorGD.php.

    To my knowledge most programs will save transparent PNGs as an 8bit image.
    On both my servers with black boxes “is_alpha_png” returns 3, therefore using imagecopymerge instead of imagecopy. On my localhost instance “is_alpha_png” correctly returns 6.

    To fix this I found 2 possible solutions:
    1)
    Save the PNG explicitly as 16bit PNG file.

    2)
    Use another function to check for transparency in the PNG file.
    This solution works fine for me (plug and play replacing “is_alpha_png”): https://stackoverflow.com/questions/5495275/how-to-check-if-an-image-has-transparency-using-gd/43996262#43996262

    Maybe you can double check it and post an update for the plugin.

    Thanks

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Oh wow, thanks for the research @steffiiiii! This is solid info and a solution. I’ll make sure to test with 8bit PNG and updated transparency checking

    Any update on this?

    Plugin Author Kuba Mikita

    (@kubitomakita)

    Hi, sorry, unfortunately no luck with the debugging and fix, but we keep this in mind and our to-do list.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Black box around PNG when scaling’ is closed to new replies.