【问题标题】:how to write images as gif to blob using imagemagick Magick++如何使用imagemagick Magick ++将图像作为gif写入blob
【发布时间】:2017-09-30 22:34:18
【问题描述】:
  vector<Magick::Image> frames;
int delay = 20;
for(auto iter=taskList.begin(); iter != taskList.end(); ++iter){
/* hide some codes here*/
  frames.push_back(*img);
}
// write images to file, works fine
Magick::writeImages(frames.begin(), frames.end(), "xxx.gif");
Magick::Blob tmpBlob;
// write images to blob, I then decode the data in blob,  
// and write this blob to yyy.gif. The gif file only contains the first frame image.
Magick::writeImages(frames.begin(), frames.end(), &tmpBlob, true);
// the length is far too small 
LOG_DEBUG("blob data length: %d", tmpBlob.length());
// read from the blob into a imagelist, and print the size of the list
// the size is 1 
vector<Magick::Image> image_list;
Magick::readImages(&image_list, tmpBlob);
LOG_DEBUG("new frames length: %d", image_list.size());

嗨,当我尝试使用 ImageMagick(版本 7.0.3)Magick++ STL.h writeImages 函数将图像列表写入 Blob 时遇到问题。它不能正常工作,似乎只有一帧被写入 blob。但是对于相同的图像列表,将它们写入 gif 文件就可以了。有人可以帮帮我吗?

【问题讨论】:

  • 问题已解决。失败的原因是我没有做img->magick("GIF"),导致无法正确写入blob。
  • 很好地找到了解决办法。请发布您的解决方案作为答案,并接受它。这将帮助未来的读者解决同样的问题。
  • link 你能帮我解决这个问题吗? @emcconville

标签: c++ imagemagick gif magick++


【解决方案1】:

问题解决了。我失败的原因是我没有做img->magick("GIF"),导致无法正确写入blob。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多