note 46441 deleted from ref.image by tularis

From: Date: Sun, 29 Jun 2008 21:11:10 +0000
Subject: note 46441 deleted from ref.image by tularis
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-140969@lists.php.net to get a copy of this message
Note Submitter: phpm at nreynolds dot me dot uk ---- A generic image loading function, determines the file format by itself. <?php function imagecreatefromfile($filename) { static $image_creators; if (!isset($image_creators)) { $image_creators = array( 1 => "imagecreatefromgif", 2 => "imagecreatefromjpeg", 3 => "imagecreatefrompng", 16 => "imagecreatefromxbm" ); } $image_size = getimagesize($filename); if (is_array($image_size)) { $file_type = $image_size[2]; if (isset($image_creators[$file_type])) { $image_creator = $image_creators[$file_type]; if (function_exists($image_creator)) { return $image_creator($filename); } } } // "imagecreatefrom...() returns an empty string on failure" return ""; } ?>

« previous php.notes (#140969) next »