diff --git a/coders/fpx.c b/coders/fpx.c
index 652428a..67c5b76 100644
--- a/coders/fpx.c
+++ b/coders/fpx.c
@@ -858,8 +858,6 @@
Initialize FPX toolkit.
*/
image->depth=8;
- if (IssRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
memory_limit=20000000;
fpx_status=FPX_SetToolkitMemoryLimit(&memory_limit);
if (fpx_status != FPX_OK)
@@ -875,6 +873,9 @@
colorspace.numberOfComponents=1;
colorspace.theComponents[0].myColor=MONOCHROME;
}
+ else
+ if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
background_color.color1_value=0;
background_color.color2_value=0;
background_color.color3_value=0;
diff --git a/coders/mat.c b/coders/mat.c
index b0b4ee8..a76b4b7 100644
--- a/coders/mat.c
+++ b/coders/mat.c
@@ -1239,10 +1239,11 @@
scene=0;
do
{
- if (IssRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
is_gray = IsImageGray(image,exception);
+ if (is_gray == MagickFalse)
+ if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
z = is_gray ? 0 : 3;
/*
diff --git a/coders/ps.c b/coders/ps.c
index d5f2290..0cb112f 100644
--- a/coders/ps.c
+++ b/coders/ps.c
@@ -1443,9 +1443,11 @@
/*
Scale relative to dots-per-inch.
*/
- if ((IssRGBColorspace(image->colorspace) == MagickFalse) &&
- (image->colorspace != CMYKColorspace))
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
+ if ((image_info->type == TrueColorType) ||
+ (IsImageGray(image,exception) == MagickFalse))
+ if ((IssRGBColorspace(image->colorspace) == MagickFalse) &&
+ (image->colorspace != CMYKColorspace))
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
delta.x=DefaultResolution;
delta.y=DefaultResolution;
resolution.x=image->resolution.x;
diff --git a/coders/psd.c b/coders/psd.c
index 0306045..bdc5084 100644
--- a/coders/psd.c
+++ b/coders/psd.c
@@ -2175,7 +2175,8 @@
(image->colorspace != CMYKColorspace)) &&
(image_info->colorspace != CMYKColorspace))
{
- if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ if ((IssRGBColorspace(image->colorspace) == MagickFalse) &&
+ (IsImageGray(image,exception) == MagickFalse))
(void) TransformImageColorspace(image,sRGBColorspace,exception);
(void) WriteBlobMSBShort(image,(unsigned short)
(image->storage_class == PseudoClass ? IndexedMode : RGBMode));
diff --git a/coders/tga.c b/coders/tga.c
index b1b6eb8..9f7332c 100644
--- a/coders/tga.c
+++ b/coders/tga.c
@@ -698,7 +698,8 @@
*/
if ((image->columns > 65535L) || (image->rows > 65535L))
ThrowWriterException(ImageError,"WidthOrHeightExceedsLimit");
- if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ if ((IssRGBColorspace(image->colorspace) == MagickFalse) &&
+ (IsImageGray(image,exception) == MagickFalse))
(void) TransformImageColorspace(image,sRGBColorspace,exception);
targa_info.id_length=0;
value=GetImageProperty(image,"comment",exception);
diff --git a/coders/viff.c b/coders/viff.c
index 52ff0f9..7b01de1 100644
--- a/coders/viff.c
+++ b/coders/viff.c
@@ -974,10 +974,11 @@
/*
Initialize VIFF image structure.
*/
- if (IssRGBColorspace(image->colorspace) == MagickFalse)
- (void) TransformImageColorspace(image,sRGBColorspace,exception);
if (IsImageGray(image,exception) != MagickFalse)
(void) SetImageStorageClass(image,DirectClass,exception);
+ else
+ if (IssRGBColorspace(image->colorspace) == MagickFalse)
+ (void) TransformImageColorspace(image,sRGBColorspace,exception);
viff_info.identifier=(char) 0xab;
viff_info.file_type=1;
viff_info.release=1;