Copy code The code is as follows:
$filename = './D243375_0.png';
$filename = realpath($filename);
if (!file_exists($filename)) {
die("The picture does not exist~!");
}
$size = getimagesize ($filename);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if("image/png" != $size['mime'] || $file_extension != "png"){
die("This is not a complete png image");
}
$img = @imagecreatefrompng ($filename);
if($img ){
ob_start("output_handler");
imagepng($img);
ob_end_flush();
}else{
die("Cannot create png graphics correctly, please check png Is the graphic intact~");
}
function output_handler($img) {
header('Content-type: image/png');
header('Content-Length:'.strlen ($img));
return $img;
}
?>
http://www.bkjia.com/PHPjc/322411.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/322411.htmlTechArticleCopy the code as follows: ?php $filename = './D243375_0.png'; $filename = realpath($ filename); if (!file_exists($filename)) { die("The picture does not exist~!"); } $size = getimagesize ($fi...