note 58685 deleted from function.image-type-to-extension by sobak

From: Date: Thu, 01 Dec 2016 13:08:48 +0000
Subject: note 58685 deleted from function.image-type-to-extension by sobak
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-207843@lists.php.net to get a copy of this message
Note Submitter: oridan at hotmail dot com ---- i used your code in the following to open different types of files depending on their 'type' (or rather, extension). the eval simply creates <? // make sure you initialize $filename as the path to the image you want to load/create list(,,$type) = getimagesize($filename); $type = image_type_to_extension($type); eval("global \$filename; \$source = imagecreatefrom$type(\$filename);"); global $source; ?> $source is then the var you can play with. saved me a big switch statement calling different "imagecreatefromjpg"/"imagecreatefromgif" functions just to do the one simple task.... open an image of varying types.

« previous php.notes (#207843) next »