PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, July 17, 2022

[FIXED] how to write images as gif to blob using imagemagick Magick++

 July 17, 2022     c++, gif, imagemagick, magick++     No comments   

Issue

  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());

hi, I have a problem when I try to write a list of Image to Blob with ImageMagick(version 7.0.3) Magick++ STL.h writeImages function. It doesn't work correctly, it seems that only one frame was written into the blob. But with the same image list, writing them to gif file works just fine. could anybody help me out?


Solution

problem solved. The reason why I failed is that I didn't do img->magick("GIF"), which cause the failure of writing to blob correctly.



Answered By - Roy Huang
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing