[HELP] How to save the GD resource into MySQL.
Posted: Thu Nov 13, 2008 9:41 pm
I created a image and got a GD resource. Can anybody tell me how to save the image which i created into database?
Thanks!
Thanks!
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
i'm afraid it's not efficient.tasairis wrote:It'd be better for you to dump that image into a file and store the filename instead.
And how do you know that? Because last I knew it was more efficient than doing it your way.00061205 wrote:i'm afraid it's not efficient.tasairis wrote:It'd be better for you to dump that image into a file and store the filename instead.
OK,i'll try, thank you for your reply.tasairis wrote:And how do you know that? Because last I knew it was more efficient than doing it your way.00061205 wrote:i'm afraid it's not efficient.tasairis wrote:It'd be better for you to dump that image into a file and store the filename instead.
yeah, i know use the BLOB type but how to get the image data from the GD resource? I can't just save the GD resource to the db.chopsmith wrote:I, too, prefer the method suggested by tasairis. However, if you want to save the image to the db, just use the BLOB field type: http://dev.mysql.com/doc/refman/5.0/en/blob.html
Code: Select all
$im = imagecreate(500,500);
$red = imagecolorallocate($im, 255,0,0);
imagefilledrectangle($im,0,0,500,500,$red);
Code: Select all
ob_start();
imagepng($oImage);
$string = ob_get_contents();
ob_end_clean();
// $string is the image in PNG format