saving image to database after rotation
Posted: Tue Feb 15, 2011 4:41 pm
Hi, I've been working on a script to rotate an image downloaded from my database. It works perfectly, however I have not been able to get the image attributes to save the new image. The image echos fine
Can anyone help me get this script to echo the $filesize, $content and attributes at the bottom of the script. Apart from the photo I can echo nothing else - nothing at all! Thanks...
Code: Select all
echo $imagevar;Code: Select all
$imcontent = $rowid['content'];
$size = $rowid['size'];
$type = $rowid['type'];
$name = $rowid['name'];
$new = imagecreatefromstring($imcontent);
$degrees = 90;
$rotate = imagerotate($new, $degrees, 0);
header('Content-type: image/jpeg');
imagejpeg($rotate, 'tmp.jpg');
$imagefile = "tmp.jpg";
$image = imagecreatefromjpeg($imagefile);
ob_start();
imagejpeg($image);
$imagevar = ob_get_contents();
ob_end_clean();
echo $imagevar;
$filesize = filesize($imagevar);
echo $filesize;
if(!get_magic_quotes_gpc()){
$filename = addslashes($filename);
}
$fp =fopen($imagevar, 'r');
$content = fread($fp, $filesize);
$content = addslashes($content);
fclose($fp);
echo $filesize;
list($width, $height, $type, $attr) = getimagesize($imagevar);
echo $width;
echo $height;
echo $type;
echo $attr;