rendered paste body<?php
require_once("dbConnect.php");
$query = "SELECT rowid, name, picoid FROM pictures";
$queryresult = pg_query($query);
while ($row = pg_fetch_array($queryresult)) {
echo $row["rowid"] . " " .$row["name"] . " " ;
Header ("Content-type: image/jpeg");
pg_query("BEGIN");
$ofp = pg_lo_open($row["picoid"], "r");
if (!$ofp) {
echo "cannot open BLOB <br />\n";
}
else {
$img = pg_lo_read_all($ofp);
$src = imagecreatefromjpeg($img);
list($width, $height) = getimagesize($img);
$newwidth = 300;
$newheight = ($height/$width) * 300;
$tmp = imagecreatetruecolor($newwidth,$newheight);
imagecopyresampled($tmp,$src,0,0,0,0,$newwidth,$newheight,$width,$height);
imagejpeg($tmp, NULL, 100);
print $tmp;
imagedestroy($src);
pg_lo_close($tmp);
pg_query("END");
}
}
?>