A black thumbnail.

From: Date: Sat, 28 Jan 2006 00:43:09 +0000
Subject: A black thumbnail.
Groups: php.general 
Request: Send a blank email to php-general+get-229383@lists.php.net to get a copy of this message
Hi: I'm trying to create a thumbnail from a jpeg stored in a long blob in mySQL. What's wrong here? I get an image that's the correct size, but it's black. Any ideas? Thanks. tedd <code> $dbQuery = "SELECT image_type, image, image_width, image_height "; $dbQuery .= "FROM pictures "; $dbQuery .= "WHERE image_Id = $pic_id"; $result = mysql_query($dbQuery) or die("Couldn't get file list"); if(mysql_num_rows($result) == 1) { $fileType = @mysql_result($result, 0, "image_type"); $fileContent = @mysql_result($result, 0, "image"); $width_orig = @mysql_result($result, 0, "image_width"); $height_orig = @mysql_result($result, 0, "image_height"); // Set a maximum height and width $width = 200; $height = 200; if ($width && ($width_orig < $height_orig)) { $width = ($height / $height_orig) * $width_orig; } else { $height = ($width / $width_orig) * $height_orig; } // Resample $image_p = imagecreatetruecolor($width, $height); $image = imagecreatefromjpeg($fileContent); imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); // Output imagejpeg($image_p, null, 100); } </code> -- -------------------------------------------------------------------------------- http://sperling.com/

« previous php.general (#229383) next »