PDA

View Full Version : imagecopyresampled


akanevsky
05-26-2005, 09:33 PM
Hi!

I am coding an image resize script, and I've ran into the following problem:

I am using imagecopyresampled to resize it. Then, if, say, it is a jpeg image, then imagejpeg($image) will output the picture. However, if I try saving $image to my database, then retrieving it and imagejpeg-ing it, it tells me that it is a non-valid imagejpeg resource. If I try to print() it, it tells me "Resource id #29"...

I assume that $image is a resource, and cannot be just saved. How do I convert it to a normal saveable image? Thanks.

Xenon
05-26-2005, 09:43 PM
you have to output the image and catch the outputstring:

ob_start();
Imagejpeg($image);
$imgstring = ob_get_contents();
ob_end_clean();

then store $imgstring in the db

akanevsky
05-26-2005, 09:54 PM
Edit: Nevermind, I figured it out already.

Edit2: Oh, thanks Xenon :) I was quicker though.