I want to open jpeg imagedata ($data) stored as a blob in MySQL database to resize with the gd php lib. can anyone tell me how to open the file data for resizing. This is what i have now (not working)
(partly displayed)
else if($image == "thumb"){
$QUERY = "SELECT imageData FROM $CATALOG_TABLE WHERE recordID = '$recordID'";
$result = @($QUERY);
$data = @MYSQL_RESULT($result,0, "imageData");
// following line is wrong?
$jpeg = ImageCreateFromString($data);
//thumbnail max size
$size = 100;
//max additional size created by margin
$margin = 10;
//draw a border?
$border = false;
//draw a drop shadow?
$shadow = true;
if($d=getimagesize($jpeg)){
$dim = ($d[1]>$d[0]) ? 1 : 0;
$mod = $size / $d[$dim];
$w = (int) ($d[0] $mod);
$h = (int) ($d[1] $mod);
$x = (int)(($size + $margin - $w) / 2);
$y = (int)(($size + $margin - $h) / 2);
//echo "<br>$w x $h";
//echo "<br>$x x $y";
header('Content-type: image/jpeg');
$src = imagecreatefromjpeg($jpeg);
$dst = imagecreate($size+($margin 2), $size+($margin 2));
$white = imagecolorallocate($dst,255,255,255);
imagefill($dst,0,0,$white);
if($border){
$black = imagecolorallocate($dst,0,0,0);
imagerectangle($dst,0,0,$size+$margin,$size+$margin,$black);
}
if($shadow){
$lighter = imagecolorallocate($dst,220,220,220);
imagefilledrectangle($dst,($x+3),($y+3),($w+$x+3),($h+$y+3),$lighter);
$light = imagecolorallocate($dst,180,180,180);
imagefilledrectangle($dst,($x+1),($y+1),($w+$x+1),($h+$y+1),$light);
$dark = imagecolorallocate($dst,140,140,140);
imagefilledrectangle($dst,($x),($y),($w+$x),($h+$y),$dark);
}
//imagecopyresampled($dst,$src,$x,$y,0,0,$w,$h,$d[0],$d[1]);
imagecopyresized($dst,$src,$x,$y,0,0,$w,$h,$d[0],$d[1]);
imagejpeg($dst);
imagedestroy($dst);
imagedestroy($src);
}