Hi Tedd, Dynamic Thumbnail generation: http://www.weberdev.com/ViewArticle-388.html On 1/28/06, tedd <tedd@xxxxxxxxxxxx> wrote: > > 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> > -- > >