This code fails in MagickResizeImage. The message "MagickResizeImage failed!" is printed in my log.
I would like to get an error detail on why MagickResizeImage is failing. How can I do that?
Thanks.
Code: Select all
if( MagickReadImage( g_Magickwand, _fb ) == MagickTrue ){
char* _Format = MagickGetImageFormat( g_Magickwand );
Formatbuffer _Original( 0 );
if( _Format != NULL ){
xx( 9, "MagickGetImageFormat %s.", _Format );
_Original( "photo/%u.%s", _Photoid, _Format );
}else{
_Original( "photo/%u", _Photoid );
}
MagickRelinquishMemory(_Format);
rename( _fb, _Original );
int _Width = MagickGetImageWidth(g_Magickwand);
int _Height = MagickGetImageHeight(g_Magickwand);
if( _Width <= Thumbnailsize && _Height <= Thumbnailsize ){
return;
}
int _Newwidth, _Newheight;
if( _Width >= _Height ){
_Newwidth = Thumbnailsize ;
float _Ratio = _Newwidth / _Width ;
_Newheight = _Height * _Ratio;
}else{
_Newheight = Thumbnailsize ;
float _Ratio = _Newheight / _Height ;
_Newwidth = _Width * _Ratio;
}
MagickBooleanType _ret = MagickResizeImage( g_Magickwand, _Newwidth,
_Newheight, LanczosFilter, 1.0 );
if( _ret == MagickTrue ){
xx( 9, "New size %dx%d.", _Newwidth, _Newheight );
}else{
xx( 1, "MagickResizeImage failed!" );
}
MagickSetImageCompressionQuality( g_Magickwand, 95 );
Formatbuffer _Convertedimage( 0 );
_Convertedimage( "photo/%u_tn.jpg", _Photoid );
MagickWriteImage( g_Magickwand, _Convertedimage );
}