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

Post any defects you find in the released or beta versions of the ImageMagick software here. Include the ImageMagick version, OS, and any command-line required to reproduce the problem. Got a patch for a bug? Post it here.
Post Reply
tezcatl
Posts: 2
Joined: 2019-06-08T16:39:35-07:00
Authentication code: 1152

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

Post by tezcatl » 2019-06-08T17:04:45-07:00

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)

User avatar
magick
Site Admin
Posts: 10994
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2019-06-09T04:11:22-07:00

This is expected behavior. Instead try this command:

Code: Select all

display -colorspace sRGB image.heic

tezcatl
Posts: 2
Joined: 2019-06-08T16:39:35-07:00
Authentication code: 1152

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

Post by tezcatl » 2019-06-09T05:07:13-07:00

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.

snibgo
Posts: 11786
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

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

Post by snibgo » 2019-06-09T07:31:39-07:00

But is your screen sRGB? How does IM's Display know what colorspace your screen needs?
snibgo's IM pages: im.snibgo.com

User avatar
magick
Site Admin
Posts: 10994
Joined: 2003-05-31T11:32:55-07:00

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

Post by magick » 2019-06-09T14:54:52-07:00

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.

Post Reply