Hi:
The following works for me. It takes an image from mySQL (which is
stored as a string, duh!) and creates a thumbnail "on the fly".
Many thanks for your ideas -- you made me think.
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 = imagecreatefromstring($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