note 47762 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:10:30 +0000
Subject: note 47762 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140964@lists.php.net to get a copy of this message
Note Submitter: thc at forestfactory dot de ---- Although there is allready one generic imagecreatfrom* function posted here, I will give you mine: you may pass the $mime and $size variables by reference for further use (i.e. you can write the image in the original mime-type by settig a variable to "image$mime" and use it as a function). As the function is calling getimagesize() by itself, there is no need to do it again in your own source. function imagecreatefromfile($file,&$mime,&$size) { if (!$size = @getimagesize($file)) { trigger_error("imagecreatefromfile($file): failed to open stream: No such file or directory ",E_USER_WARNING); return false; } list($image,$mime) = explode("/",$size["mime"]); $mime = strtolower($mime); if (!function_exists("imagecreatefrom$mime")) { trigger_error("imagecreatefromfile(): Mimetype (<i>$size[mime]</i>) is not supported by this version of GD",E_USER_WARNING); return false; } $createStr = "imagecreatefrom$mime"; return $createStr($file); }

« previous php.notes (#140964) next »