MIFF format for grayscale images?

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Locked
Jason S
Posts: 103
Joined: 2010-12-14T19:42:12-07:00
Authentication code: 8675308

MIFF format for grayscale images?

Post by Jason S »

The MIFF documentation does not say how grayscale images are formatted, but IM can successfully write and read them. By experimentation, I see that, for various color types, the samples in a scanline have the following arrangements:

Code: Select all

RGB:    RGBRGBRGBRGBRGBRGBRGBRGB
Gray:   gggggggg0000000000000000
RGBA:   RGBARGBARGBARGBARGBARGBARGBARGBA
GrayA:  gAgAgAgAgAgAgAgA0000000000000000
(This would be for an image 8 pixels wide.)

That is, for grayscale images, each scanline is padded with "0" samples to make it use as much space as it would if it were a color image.

Padding with 0s seems odd to me, so I'm wondering if this is by design, or what.

To test this, I'm using commands similar to the following, with IM 6.7.2-1.

Code: Select all

convert logo: -type TrueColor -resize 8x8! -depth 8 -compress none -strip rgb.miff
convert logo: -type Grayscale -resize 8x8! -depth 8 -compress none -strip gray.miff
convert logo: -type TrueColorMatte -resize 8x8! -depth 8 -compress none -strip rgba.miff
convert logo: -type GrayscaleMatte -resize 8x8! -depth 8 -compress none -strip graya.miff

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

Re: MIFF format for grayscale images?

Post by magick »

You found a bug. We'll get a patch into ImageMagick 6.7.2-2 Beta within a day or two. Thanks.

User avatar
anthony
Posts: 8884
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: MIFF format for grayscale images?

Post by anthony »

Note that internally a gray image is actually in memory as a RGB image, because of this any RGB image that only contains gray colors will be converted to a gray MIFF image on save.

Also note that there was a recent change such that if the image being saved as MIFF is marked as "sRGB" (a IMv6 mark saying the image was sRGB and is currently converted to linear-RGB) then the image will remain sRGB even if the image only contains gray colors. That is because to convert it to gray will cause the image to loose its sRGB significance in the intermediate image causing problems further down the pipeline. IM does not have a "sGRAY" colorspace.

Aside, IMv7 will see "sRGB" to really mean a "sRGB" image, and not "sRGB converted to linear RGB"
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/

Locked