Currently, I would like to create transparent png with the lowest quality.
The code:
<?php function createImg ($src, $dst, $width, $height, $quality) { $newImage = imagecreatetruecolor($width,$height); $source = imagecreatefrompng($src); //imagecreatefrompng() returns an image identifier representing the image obtained from the given filename. imagecopyresampled($newImage,$source,0,0,0,0,$width,$height,$width,$height); imagepng($newImage,$dst,$quality); //imagepng() creates a PNG file from the given image. return $dst; } createImg ('test.png','test.png','1920','1080','1'); ?>
However, there are some problems:
Do I need to specify a png file before creating a new file? Or can I create without any existing png file?
Warning: imagecreatefrompng (test.png): could not open the stream: there is no such file or directory in
C: \ DSPadmin \ DEV \ ajax_optipng1.5 \ create.php on line 4
Despite the fact that there is an error message, it still generates a png file, however, I found that it is a black file, do I need to specify any parameter to make it transparent?
Thanks.
user782104
source share