PDA

View Full Version : image retrieval from database not working?



Informer45
12-10-2004, 07:50 AM
my prob.:iam getting image from database
but not able to convert that image(resize taht is).
Warning: getimagesize: Unable to open 'ÿØÿá›Exif' for reading. in c:\apache\htdocs\upload\sho1.php on line 19

my php code:
/ database connection
$conn = mysql_connect("localhost") OR DIE (mysql_error());
@mysql_select_db ("beebaho", $conn) OR DIE (mysql_error());
$sql = "SELECT * FROM images WHERE Id=4";
$result = mysql_query ($sql, $conn);
if (mysql_num_rows ($result)>0) {
$row = @mysql_fetch_array ($result);
$image_type = $row["image_type"];
global $maxH,$maxW,$image,$imgInfo,$imgwidth,$imgheight;
$image = $row["pic"];

// echo $image;

$imgInfo= getimagesize($image);

$imgwidth = $imgInfo[0];
$imgheight = $imgInfo[1];
$maxW=200;
$maxH=300;
if ($imgwidth > $maxW) {
$ration = $maxW/$imgwidth;
$newwidth = round($imgwidth*$ration);
$newheight = round($imgheight*$ration);
if ($newheight > $maxH) {
$ration = $maxH/$newheight;
$newwidth = round($newwidth*$ration);
$newheight = round($newheight*$ration);
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
} else {
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
}
} else if ($imgheight > $maxH) {
$ration = $maxH/$imgheight;
$newwidth = round($imgwidth*$ration);
$newheight = round($imgheight*$ration);
if ($newwidth > $maxW) {
$ration = $maxW/$newwidth;
$newwidth = round($newwidth*$ration);
$newheight = round($newheight*$ration);
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
} else {
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
}
} else {
return array("image" => $image, "width" => $newwidth, "height" => $newheight);
echo $image;
}



// Header ("Content-type: $image_type");
echo $image;
}
?>


if comment "$imgInfo= getimagesize($image);"
and "echo $image;"
then it works but image is very large

Deep13
12-18-2004, 01:05 PM
I hope the image path you have specified in the database match with the actually path of the image..

and 2nd thing...

in that warning..why it is not displaying the image ext? are u stroing image name without ext or something?

Deep