ico decode from blob failed
Posted: 2012-10-23T20:15:57-07:00
I use the ImageMagick-6.7.9-10 installed from source code on linux,and then write a very simple code to test IM API for for format conversion.like following:
run the program like this:"./zhuan input format output";
when i run it with ,it works well.
then i change the way,code like this:
the load2str function just read the file content into a string in memory.when i run the second program,it prints ":Magick: no decode delegate for this image format `' @ error/blob.c/BlobToImage/361, url:favicon.ico"
I can not figure out why it does not work.At a glance,there are really some difference in getting the original image between use the Image constructor and read from blob.
In my opinion,no matter read from a disk file,or read from a in-memory blob,the same input file should be process the same.Is that right?
Code: Select all
Image image(argv[1]);
image.magick( argv[2] ); // Set JPEG output format
cout<<"File Name after magick:"<<image.fileName()<<endl;
image.write(argv[3]);
Geometry origgeo = image.size();
int width = origgeo.height();
int height = origgeo.width();
cout<<"w:"<<width<<",h:"<<height<<endl;
when i run it with ,it works well.
then i change the way,code like this:
Code: Select all
string strPic = TC_File::load2str(argv[1]);
char* data = strPic.c_str();
size_t len = strPic.length();
m_blob.update(data, len);
//m_blob.updateNoCopy(data,len);
m_image.read(m_blob);
m_image.magick(argv[2])
image.write(argv[3]);
Geometry origgeo = image.size();
int width = origgeo.height();
int height = origgeo.width();
cout<<"w:"<<width<<",h:"<<height<<endl;
I can not figure out why it does not work.At a glance,there are really some difference in getting the original image between use the Image constructor and read from blob.
In my opinion,no matter read from a disk file,or read from a in-memory blob,the same input file should be process the same.Is that right?