<?php
$filename = './D243375_0.png';
$filename = realpath($filename);
if (!file_exists($filename)) {
die("图片不存在~!");
}
$size = getimagesize ($filename);
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if("image/png" != $size['mime'] || $file_extension != "png"){
die("这不是一张完整的png图片");
}
$img = @imagecreatefrompng ($filename);
if($img){
ob_start("output_handler");
imagepng($img);
ob_end_flush();
}else{
die("不能正确的创建png图形,请检查png图形是否完好~");
}
function output_handler($img) {
header('Content-type: image/png');
header('Content-Length:'.strlen($img));
return $img;
}
?>
检测png图片是否完整的php代码
内容版权声明:除非注明,否则皆为本站原创文章。
转载注明出处:http://www.heiqu.com/a96c461fdb6ec9770bcada372d55a358.html