better error message for "unsupported colorspace"

we just printed the enum number before
This commit is contained in:
John Cupitt 2019-05-24 17:42:10 +01:00
parent 5855321638
commit 02bdb8b96c
4 changed files with 60 additions and 2 deletions

View File

@ -1,5 +1,6 @@
24/5/19 started 8.8.1
- improve realpath() use on older libc
- better magickload error messages
21/9/18 started 8.8.0
- much faster smartcrop [lovell]

View File

@ -403,6 +403,60 @@ magick_set_image_option( ImageInfo *image_info,
#endif /*HAVE_SETIMAGEOPTION*/
}
typedef struct _MagickColorspaceTypeNames {
ColorspaceType colorspace;
const char *name;
} MagickColorspaceTypeNames;
static MagickColorspaceTypeNames magick_colorspace_names[] = {
{ UndefinedColorspace, "UndefinedColorspace" },
{ CMYColorspace, "CMYColorspace" },
{ CMYKColorspace, "CMYKColorspace" },
{ GRAYColorspace, "GRAYColorspace" },
{ HCLColorspace, "HCLColorspace" },
{ HCLpColorspace, "HCLpColorspace" },
{ HSBColorspace, "HSBColorspace" },
{ HSIColorspace, "HSIColorspace" },
{ HSLColorspace, "HSLColorspace" },
{ HSVColorspace, "HSVColorspace" },
{ HWBColorspace, "HWBColorspace" },
{ LabColorspace, "LabColorspace" },
{ LCHColorspace, "LCHColorspace" },
{ LCHabColorspace, "LCHabColorspace" },
{ LCHuvColorspace, "LCHuvColorspace" },
{ LogColorspace, "LogColorspace" },
{ LMSColorspace, "LMSColorspace" },
{ LuvColorspace, "LuvColorspace" },
{ OHTAColorspace, "OHTAColorspace" },
{ Rec601YCbCrColorspace, "Rec601YCbCrColorspace" },
{ Rec709YCbCrColorspace, "Rec709YCbCrColorspace" },
{ RGBColorspace, "RGBColorspace" },
{ scRGBColorspace, "scRGBColorspace" },
{ sRGBColorspace, "sRGBColorspace" },
{ TransparentColorspace, "TransparentColorspace" },
{ xyYColorspace, "xyYColorspace" },
{ XYZColorspace, "XYZColorspace" },
{ YCbCrColorspace, "YCbCrColorspace" },
{ YCCColorspace, "YCCColorspace" },
{ YDbDrColorspace, "YDbDrColorspace" },
{ YIQColorspace, "YIQColorspace" },
{ YPbPrColorspace, "YPbPrColorspace" },
{ YUVColorspace, "YUVColorspace" },
{ LinearGRAYColorspace, "LinearGRAYColorspace" }
};
const char *
magick_ColorspaceType2str( ColorspaceType colorspace )
{
int i;
for( i = 0; i < VIPS_NUMBER( magick_colorspace_names ); i++ )
if( magick_colorspace_names[i].colorspace == colorspace )
return( magick_colorspace_names[i].name );
return( "<unknown ColorspaceType>" );
}
/* ImageMagick can't detect some formats, like ICO, by examining the contents --
* ico.c simply does not have a recogniser.
*

View File

@ -61,11 +61,14 @@ void *magick_profile_map( Image *image, MagickMapProfileFn fn, void *a );
int magick_set_profile( Image *image,
const char *name, const void *data, size_t length,
ExceptionInfo *exception );
void magick_set_image_option( ImageInfo *image_info,
const char *name, const char *value );
void magick_set_number_scenes( ImageInfo *image_info,
int scene, int number_scenes );
const char *magick_ColorspaceType2str( ColorspaceType colorspace );
ExceptionInfo *magick_acquire_exception( void );
void magick_destroy_exception( ExceptionInfo *exception );
void magick_inherit_exception( ExceptionInfo *exception, Image *image );

View File

@ -497,8 +497,8 @@ vips_foreign_load_magick7_parse( VipsForeignLoadMagick7 *magick7,
default:
vips_error( class->nickname,
_( "unsupported colorspace %d" ),
(int) image->colorspace );
_( "unsupported colorspace %s" ),
magick_ColorspaceType2str( image->colorspace ) );
return( -1 );
}