Thanks to visit codestin.com
Credit goes to github.com

Skip to content

imagecopyresampled() produce artifacts on transparent PNG #661

@jskp4

Description

@jskp4

imagecopyresampled() produce many artifacts on transparent PNG.
I added a yellow layer to the output image to make the artifacts easier to see.
In the test code below a small resolution (thumbnail) is used on the output image, but similar artifacts also appear in higher resolutions.
Everything worked well on previous GD version (2.0 I think), but after the upgrade on v 2.2.5, the artifacts began to appear.
I was looking for a solution on the internet, but I did not find anything functional, it is probably a bug in the function imagecopyresampled().

Test code:

$img_src = imagecreatefrompng('source.png');
$img_dest = imagecreatetruecolor(225, 225);
imagealphablending($img_dest, false);
imagesavealpha($img_dest, true);
imagecopyresampled($img_dest, $img_src, 0, 0, 0, 0, 225, 225, 2000, 2000);
imagepng($img_dest, 'imagecopyresampled1.png');

Input image:
source

Output image:
imagecopyresample1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions