Fixed issue with grayscale images.

This commit is contained in:
Dirk Lemstra 2017-12-22 22:06:11 +01:00
parent e8df2aa190
commit 6b0f676a5e

View File

@ -94,6 +94,13 @@ magick_set_image_size( Image *image, const size_t width, const size_t height,
return SetImageExtent( image, width, height, exception );
}
static int
magick_set_image_colorspace( Image *image, const ColorspaceType colorspace,
ExceptionInfo *exception)
{
return SetImageColorspace( image, colorspace, exception );
}
static int
magick_import_pixels( Image *image, const ssize_t x, const ssize_t y,
const size_t width, const size_t height, const char *map,
@ -143,6 +150,14 @@ magick_set_image_size( Image *image, const size_t width, const size_t height,
return SetImageExtent( image, width, height );
}
static int
magick_set_image_colorspace( Image *image, const ColorspaceType colorspace,
ExceptionInfo *exception)
{
(void) exception;
return SetImageColorspace( image, colorspace );
}
static int
magick_import_pixels( Image *image, const ssize_t x, const ssize_t y,
const size_t width, const size_t height, const char *map,
@ -350,6 +365,11 @@ magick_create_image( Write *write, VipsImage *im )
if( !magick_set_image_size( image, im->Xsize, im->Ysize, write->exception ) )
return( -1 );
if( im->Bands < 3) {
if (! magick_set_image_colorspace( image, GRAYColorspace, write->exception ) )
return( -1 );
}
write->current_image=image;
magick_set_properties( write );
status = vips_sink_disc( im, magick_write_block, write );