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 MCNP里如何定义多个源?
  • ¥20 双层网络上信息-疾病传播
  • ¥50 paddlepaddle pinn
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏