note 57368 deleted from ref.image by didou
| From: | didou@php.net | Date: | Sun, 23 Apr 2006 23:01:44 +0000 |
| Subject: | note 57368 deleted from ref.image by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-109252@lists.php.net to get a copy of this message | ||
Note Submitter: stephan dot klein at gmx dot at
----
I was looking for a function to determine whether a variable is a valid image ressource. After a bit
of thinking I came up with this pretty fast solution:
<?php
function is_gd_handle($var) {
ob_start();
imagecolorallocate($var, 255, 255, 255);
$error = ob_get_contents();
ob_end_clean();
if(preg_match('/not a valid Image resource/',$error)) {
return false;
} else {
return true;
}
}
?>
Hope it saved somebody some time!