开发者

How to store image created by PHP imagecopymerge function in mysql database

I'm trying to overlay a series of images on top of one another and save the result to a开发者_JAVA百科 mysql database in a blob field. I'm using codeigniter's 'active-record' syntax to do this. I'm running into the following error:

Error Number: 1064</p><p>You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'id #48 WHERE `id` = '5'' at line 1
UPDATE `users_thumbnails` SET `thumbnail` = Resource id #48 WHERE `id` = '5'    

Can someone explain what I'm doing wrong? Thanks!

$base = imagecreatefromjpeg('application/assets/images/vel1_bg.jpg');
    foreach($array as $key => $value){
                $item = imagecreatefrompng('application/assets/images/items/item' . $value[0] . '.png');
                list($width, $height, $type, $attr) = getimagesize('application/assets/images/items/item'. $value[0] . '.png');
                imagecopymerge($base, 
                            $item,
                            $value[1],
                            $value[2],
                            0,
                            0,
                            $width,
                            $height,
                            100);
                //imagedestroy($item);
            }

    $data = array('thumbnail' => $base);
    $this->db->where('fbid', $this->session->userdata('id'));
    $this->db->update('users_thumbnails', $data);


use

  ...
 ob_start();
 imagepng($base);
 $baseimg = ob_get_clean();
 $data = array('thumbnail' => $baseimg);
  ...

else $base is not automatically converted to an image when you pass it to the query it simply converts as Resource id #48

Edit: capture the contents

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜