Check out this article : http://www.weberdev.com/ViewArticle-3.html

Sincerely 
 
berber 
 
Visit the Weber Sites Today, 
To see where PHP might take you tomorrow. 
PHP & MySQL Forums : http://www.weberforums.com
Learn PHP & MySQL Playing Trivia : http://www.webertrivia.com
Free Uptime Monitor : http://uptime.weberdev.com
 

-----Original Message-----
From: tedd [mailto:[EMAIL PROTECTED] 
Sent: Saturday, January 28, 2006 2:43 AM
To: php-general@lists.php.net
Subject: [PHP] A black thumbnail.

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/

--
PHP General Mailing List (http://www.php.net/) To unsubscribe, visit:
http://www.php.net/unsub.php

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


Reply via email to