Binary Content from Image Resource

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Ok all im probably missing something really simple here but i cant find
a function in the gd lib function list that would let me do this. Im
probably just slow today.

Im doing a scaling script which im pretty sure is working great except
one of my goals is to never have to write this stuff to a temporary
file. I store all of my images in the db so when i make this new scaled
image, id like to just add it as a new image to the db.

right now im doing a bunch of stuff and then these 2 lines

$scaledImage = imagecreatetruecolor($targetWidth,$targetHeight);
imagecopyresampled($scaledImage, $originalImage, 0, 0, 0, 0,
$targetWidth, $targetHeight, $originalWidth, $originalHeight);

That leaves me with $scaledImage as a php image resource containing
what i need. My question is this:

How do i get the binary data out of $scaledImage so that i can then
write that to the db. I already have scripts written to add binary data
to a database, its the actually pulling that information out of
$scaledImage that i cant figure out.  

Any idea?

Re: Binary Content from Image Resource

Areric wrote:
Quoted text here. Click to load it

A workaround would be this:
   ob_start(); // start a new output buffer
   imagejpeg( $newimage, NULL, 100 );
   $ImageData = ob_get_contents();
   ob_end_clean; // stop this output buffer

Re: Binary Content from Image Resource

Ahh. i saw that on the php pages but i didnt really get that it was a
workaround for what i want, Thanks Sjoerd

Site Timeline