[Solved] imagepng() expects parameter 1 to be resource [closed]


Read the manual! You have to first obtain an image resource, returned by one of the image creation functions, such as imagecreatefrompng():

$file = $PNG_WEB_DIR.basename($filename);
$img  = imagecreatefrompng($file);

// ...

ob_start("output_handler");
imagepng($img,NULL,9);
$image_data = ob_get_contents();
ob_end_flush();

4

solved imagepng() expects parameter 1 to be resource [closed]