note 100185 added to function.imagecreatefrompng

From: Date: Wed, 29 Sep 2010 22:58:03 +0000
Subject: note 100185 added to function.imagecreatefrompng
Groups: php.notes 
Request: Send a blank email to php-notes+get-172828@lists.php.net to get a copy of this message
Hey, I just want to add for those of you who're having problem creating thumbs from png files - when you're using the "imagepng()" function put it in a variable. If you don't put it you'll probably be wondering why you're page will offer you to download itself rather than resizing it. Example: public function resizeFile($fileInfo) { $image = $fileInfo['name']; $uploadedfile = $fileInfo['full']; if ($image) { $filename = stripslashes($fileInfo['name']); $extension = $fileInfo['ext']; $extension = strtolower($extension); $size = filesize($fileInfo['full']); if ($size > $this->maxSize * 1024) { die('You have exceeded the size limit!'); } $uploadedfile = $fileInfo['full']; $src = imagecreatefromstring($uploadedfile); list($width, $height) = getimagesize($uploadedfile); $newwidth = 130; $newheight = ($height / $width) * $newwidth; $tmp = imagecreatetruecolor($newwidth, $newheight); imagecopyresampled($tmp, $src, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); $filenameThumb = "images/thumbs/" . $fileInfo['name']; if($extension == ("jpg" || "jpeg")) imagejpeg($tmp, $filenameThumb, 100); else if($extension == "png") // Disallow png display - this will create an image but won't display it! $tmpPng = imagePNG($tmp, $filenameThumb, 100); else imagegif($tmp, $filenameThumb, 100); imagedestroy($src); imagedestroy($tmp); } else { die("Fatal error."); } } ---- Server IP: 69.147.83.197 Probable Submitter: 85.91.149.4 ---- Manual Page -- http://www.php.net/manual/en/function.imagecreatefrompng.php Edit -- https://master.php.net/note/edit/100185 Del: integrated -- https://master.php.net/note/delete/100185/integrated Del: useless -- https://master.php.net/note/delete/100185/useless Del: bad code -- https://master.php.net/note/delete/100185/bad+code Del: spam -- https://master.php.net/note/delete/100185/spam Del: non-english -- https://master.php.net/note/delete/100185/non-english Del: in docs -- https://master.php.net/note/delete/100185/in+docs Del: other reasons-- https://master.php.net/note/delete/100185 Reject -- https://master.php.net/note/reject/100185 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#172828) next »