_php Tutorial to detect whether a PNG picture is complete PHP code

Source: Internet
Author: User
Copy CodeThe code is as follows:
$filename = './d243375_0.png ';
$filename = Realpath ($filename);
if (!file_exists ($filename)) {
Die ("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 full PNG image");
}
$img = @imagecreatefrompng ($filename);
if ($img) {
Ob_start ("Output_handler");
Imagepng ($IMG);
Ob_end_flush ();
}else{
Die ("Do not create PNG graphics correctly, please check if PNG graphics are intact ~");
}
function Output_handler ($img) {
Header (' content-type:image/png ');
Header (' Content-length: '. strlen ($img));
return $img;
}
?>

http://www.bkjia.com/PHPjc/322411.html www.bkjia.com true http://www.bkjia.com/PHPjc/322411.html techarticle Copy the code as follows: Php $filename = './d243375_0.png '; $filename = Realpath ($filename); if (!file_exists ($filename)) {die ("picture Not exist ~ ");} $size = getimagesize ($fi ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.