note 57282 deleted from function.getimagesize by mazzanet
| From: | mazzanet@php.net | Date: | Mon, 28 Jan 2008 11:09:04 +0000 |
| Subject: | note 57282 deleted from function.getimagesize by mazzanet | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-135467@lists.php.net to get a copy of this message | ||
Note Submitter: cvig at raw-io dot com
----
This function does not work to catch corrupted PNG images. The alternative is to use
ImageMagick's identify tool. Due to some sort of odd output usage the output from
ImageMagick's identify won't be returned but you can use the return value from the program
to test if a PNG file is valid:
#!/usr/bin/php
<?php
if (! $argv[1])
exit("$argv[0] filename.png\n");
$result = 0;
$tmp;
exec("identify $argv[1]", $tmp, $result);
if($result)
{
echo "Corrupted image\n";
return FALSE; // corrupt PNG file
}
else
{
echo "Valid image\n";
return TRUE;
}
?>