- 论坛徽章:
- 0
|
在使用ImageMagick做TIFF文件转换时出现如下警告:
Ping Warning:ImageMagick: 001.TIF: Line length mismatch at line 0 of strip 0 (got 4410, expected 2704). `Fax4Decode'
Read Warning:ImageMagick: 001.TIF: Line length mismatch at line 0 of strip 0 (got 4410, expected 2704). `Fax4Decode'
操作系统:SUSE10 SP1
ImageMagick:ImageMagick-6.4.4-10
libtiff:tiff-3.8.2
gcc:gcc-4.1.2_20070115-0.11
代码如下,请高手指点:
/**
* shell>gcc -I/usr/local/ImageMagick/include/ImageMagick -L/usr/local/ImageMagick/lib -lMagick++ -o test test.cpp
*/
#include <iostream>
#include <sstream>
#include <Magick++.h>
using namespace std;
using namespace Magick;
string PingImage( string file_name )
{
Image image;
try
{
image.ping( file_name );
}
catch( Warning &E )
{
cerr << "Ping Warning:" << E.what() << endl;
}
catch( Exception &E )
{
return "Ping Error:"+string(E.what());
}
return "";
}
string RenderImage( string file_name, string type, double size, double angle)
{
Image image;
Blob blob;
string msg;
if((msg = PingImage(file_name)) != "")
{
return msg;
}
cerr << "Read Image Start..." <<endl;
try
{
image.read(file_name);
}
catch( Warning &E )
{
cerr << "Read Warning:" << E.what() <<endl;
}
catch( Exception &E )
{
cerr << "Read Error:" << E.what() << endl;
return string(E.what());
}
image.magick( type.c_str() );
if( strcasecmp(type.c_str(),"TIFF") == 0 || strcasecmp(type.c_str(),"TIF") == 0 )
image.compressType(Group4Compression);
else
{
image.type(PaletteType);
image.depth(8);
image.quantizeColors(32);
}
if( size!=0 )
{
ostringstream str;
str << size;
cerr << "size:" << str.str().c_str()<< endl;
image.zoom(str.str().c_str());
}
if( angle!=0 )
image.rotate(angle);
cerr << "angle:" << angle << endl;
image.write( &blob );
Image image_from_blob(blob);
image_from_blob.write("image_from_blob.png");
return string((char *)blob.data(),(long)blob.length());
}
int main(int, char* argV[])
{
char *filename;
int filename_len;
char *type1;
int type_len;
double size;
double angle;
strcpy(filename,"001.TIF");
string img = RenderImage(string(filename),"png", 0, 0);
} |
另外:将此代码作为php的扩展模块使用时,提示如下错误,然后程序直接退出了。try...catch{Warning &E}或catch( Magick::WarningCoder &warning )
根本捕捉不到错误。
terminate called after throwing an instance of 'Magick::WarningCoder' what(): ImageMagick: 001.TIF: Line length mismatch at line 0 of strip 0 (got 4410, expected 2704). `Fax4Decode'
我查了写资料,在ImageMagic网站:http://www.imagemagick.org/Magick++/Exception.html
解释说
Warnings issued by some coders.
但是还是不知道该如何处理。 |
|