When using the command imagecreatefrompng('source.png'), my browsers will not display any images. Google Chrome shows a big black screen with a small 16*16 square in the center and Microsoft Edge tries to download an image that cannot be displayed.
When opening a jpg with the command imagecreatefromjpg, the codes do seem to function.
I have no idea whats going wrong, even when straight up copying the code from my sources.
I have been using various sources, such as:
https://www.codepunker.com/blog/how-to-merge-png-files-with-php-and-GD-Library
Note: No errors are being displayed.
As per request, I have been using the exact code as my source:
<?php
// https://www.codepunker.com/blog/how-to-merge-png-files-with-php-and-GD-Library
//define the width and height of our images
define("WIDTH", 200);
define("HEIGHT", 200);
$dest_image = imagecreatetruecolor(WIDTH, HEIGHT);
//make sure the transparency information is saved
imagesavealpha($dest_image, true);
//create a fully transparent background (127 means fully transparent)
$trans_background = imagecolorallocatealpha($dest_image, 0, 0, 0, 127);
//fill the image with a transparent background
imagefill($dest_image, 0, 0, $trans_background);
//take create image resources out of the 3 pngs we want to merge into destination image
$a = imagecreatefrompng('1.png');
$b = imagecreatefrompng('2.png');
$c = imagecreatefrompng('3.png');
//copy each png file on top of the destination (result) png
imagecopy($dest_image, $a, 0, 0, 0, 0, WIDTH, HEIGHT);
imagecopy($dest_image, $b, 0, 0, 0, 0, WIDTH, HEIGHT);
imagecopy($dest_image, $c, 0, 0, 0, 0, WIDTH, HEIGHT);
//send the appropriate headers and output the image in the browser
header('Content-Type: image/png');
imagepng($dest_image);
//destroy all the image resources to free up memory
imagedestroy($a);
imagedestroy($b);
imagedestroy($c);
imagedestroy($dest_image);
?>
I have also checked my phpinfo(), all GD types have been enabled on my Xampp server.