doulvli9462 2012-01-04 00:00
浏览 47
已采纳

Imagick和GridFS

I have images stored in GridFS for MongoDB. When I pull the image out, I want to resize it and then store it back into the database. I tried this:

$image = $grid_collection ->findOne(array('_id' => new MongoID($id)));
new Imagick($image -> getBytes());

But that throws an error in Imagick. Now I can write it out to file temporarily to disk and have Imagick read the file, but that seems the long way around. Any suggestions on a better way to do this?

  • 写回答

2条回答 默认 最新

  • doupeng6890 2012-01-04 00:07
    关注

    Yes:

    $data = $grid->findOne(array('_id' => new MongoID($id)));
    
    $img = new Imagick();
    $img->readImageBlob($data->getBytes());
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 matlab求解平差
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法