Page 1 of 1

[PATCH] display command does'nt change colorspace to sRGB if needed

Posted: 2019-06-08T17:04:45-07:00
by tezcatl
I've compiled imagemagick support for HEIC and i've noticed that the display command displays my pictures with the wrong colorspace. After having looking into the code i noticed that the readimage function returned images using the YCbCr colorspace and that the display command tried to display it without changing the colorspace to sRGB.

Here is proposal patch for fixing this issue (imagemagick 7) :

diff --git a/MagickWand/display.c b/MagickWand/display.c
index a63ec7a51..eca8c047d 100644
--- a/MagickWand/display.c
+++ b/MagickWand/display.c
@@ -487,6 +487,11 @@ WandExport MagickBooleanType DisplayImageCommand(ImageInfo *image_info,
(void) CopyMagickString(image_info->filename,filename,MagickPathExtent);
images=ReadImage(image_info,exception);
CatchException(exception);
+ if (images->colorspace != sRGBColorspace)
+ {
+ (void) TransformImageColorspace(images,sRGBColorspace,exception);
+ CatchException(exception);
+ }
status&=(images != (Image *) NULL) &&
(exception->severity < ErrorException);
if (images == (Image *) NULL)

Re: [PATCH] display command does'nt change colorspace to sRGB if needed

Posted: 2019-06-09T04:11:22-07:00
by magick
This is expected behavior. Instead try this command:

Code: Select all

display -colorspace sRGB image.heic

Re: [PATCH] display command does'nt change colorspace to sRGB if needed

Posted: 2019-06-09T05:07:13-07:00
by tezcatl
Yes, this works but my feeling is it would be nice to set it as a default behaviour. If you are, like me, a new user, you would probably expect the display command to work "out of the box" without figuring out the settings to display it correctly.

Re: [PATCH] display command does'nt change colorspace to sRGB if needed

Posted: 2019-06-09T07:31:39-07:00
by snibgo
But is your screen sRGB? How does IM's Display know what colorspace your screen needs?

Re: [PATCH] display command does'nt change colorspace to sRGB if needed

Posted: 2019-06-09T14:54:52-07:00
by magick
ImageMagick has a hands-off philosophy. We assume the user knows what they are doing so we don't touch the image attributes, including the colorspace, without an explicit command-line option.