Support » Plugin: Image Watermark » Transparent PNG's

Viewing 1 replies (of 1 total)
  • Hey,

    I came across the same issue, went through all the threads I could find but I finally managed after a few research of my own to find the solution to the transparent PNG backgrounds that go black.

    Here is how:

    Open the ‘image-watermark.php’ file from the plugin folder and go to line 1275 (version 1.3.3 of the plugin), or find the function named ‘private function get_image_resource($filepath, $mime_type)’

    Then, just add this : imagesavealpha($res, true);
    After the line : $res = imagecreatefrompng($filepath);

    I also noticed something weird at the line right after, which was like this:
    $transparent = imagecolorallocatealpha($res, 255, 255, 254, 127);

    I thought the third ‘254’ should be ‘255’ to match the transparency, so I just changed that line too to this:
    $transparent = imagecolorallocatealpha($res, 255, 255, 255, 127);

    After these 2 changes, the function should look like this:

    private function get_image_resource($filepath, $mime_type)
    			case 'image/jpeg':
    			case 'image/pjpeg':
    				return imagecreatefromjpeg($filepath);
    			case 'image/png':
    				$res = imagecreatefrompng($filepath);
                                    imagesavealpha($res, true);
    				$transparent = imagecolorallocatealpha($res, 255, 255, 255, 127);
    				imagefilledrectangle($res, 0, 0, imagesx($res), imagesy($res), $transparent);
    				return $res;
    				return FALSE;

    Hope this helps! it was such a shame that this beautiful plugin was missing that.
    Maybe the author should consider updating so this doesn’t happen anymore 😉

    Thanks again for the amazing plugin!

Viewing 1 replies (of 1 total)
  • The topic ‘Transparent PNG's’ is closed to new replies.