note 46441 added to ref.image

From: Date: Mon, 11 Oct 2004 19:48:18 +0000
Subject: note 46441 added to ref.image
Groups: php.notes 
Request: Send a blank email to php-notes+get-78363@lists.php.net to get a copy of this message
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 ""; } ?> ---- Manual Page -- http://www.php.net/manual/en/ref.image.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+46441 Delete -- http://master.php.net/manage/user-notes.php?action=delete+46441&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+46441&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#78363) next »