Note that in IMv7 there is a clear way for it to decide if an image is grayscale or not.
If it has a single channel it is grayscale. three channels color.
IMv6 unfortunately does not internally have single channel images.
sampling-factor always similar
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: sampling-factor always similar
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/
Re: sampling-factor always similar
lahabana wrote:For sure here it is:
GreenKoopa wrote:convert gray.jpg -type TrueColor gray_to_rgb.jpg
convert gray_to_rgb.jpg -format "%r %[channels] %[colorspace]" info:-
PseudoClass Gray gray Gray <= Case 5: fail (the case lahabana needed)
Did this regress? I just tried this with ImageMagick 6.8.8-2 built from source on Debian GNU/Linux sid with Debian package libjpeg8-dev version 8d-2, and I saw the same failure GreenKoopa saw with the sample from lahabana.magick wrote:Its a bug and its already fixed. Look for a patch in ImageMagick 6.8.5-7 by sometime tomorrow. Thanks.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: sampling-factor always similar
I get no error message for this on IM 6.8.8.2 Q16 Mac OSX
convert 3.jpg -type truecolor 3b.jpg
convert 3b.jpg -format "%r %[channels] %[colorspace]" info:
PseudoClass Gray gray Gray
IM apparently reports a gray image, because it knows it has 3 equal channels. Other tools will likely report it as sRGB, because it sees 3 channels and does not care if equal or not.
see
viewtopic.php?f=2&t=24801
convert 3.jpg -type truecolor 3b.jpg
convert 3b.jpg -format "%r %[channels] %[colorspace]" info:
PseudoClass Gray gray Gray
IM apparently reports a gray image, because it knows it has 3 equal channels. Other tools will likely report it as sRGB, because it sees 3 channels and does not care if equal or not.
see
viewtopic.php?f=2&t=24801
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: sampling-factor always similar
I did a test with grayscale jpg and png and Exiftool does not recognize the 3 channels. Perhaps other format specific tools will know the difference.
convert rose: -colorspace gray -type truecolor rose_gray.jpg
Fred-Weinhauss-Mac-mini:desktop fred$ exiftool -s -ee -g1 -u -n -D rose_gray.jpg---- ExifTool ----
- ExifToolVersion : 8.71
---- System ----
- FileName : rose_gray.jpg
- BitsPerSample : 8
- ColorComponents : 1
---- Composite ----
- ImageSize : 70x46
convert rose: -colorspace gray -type truecolor rose_gray.png
Fred-Weinhauss-Mac-mini:desktop fred$ exiftool -s -ee -g1 -u -n -D rose_gray.png---- ExifTool ----
- ExifToolVersion : 8.71
---- System ----
- FileName : rose_gray.png
0 ImageWidth : 70
4 ImageHeight : 46
8 BitDepth : 8
9 ColorType : 0
convert rose: -colorspace gray -type truecolor rose_gray.jpg
Fred-Weinhauss-Mac-mini:desktop fred$ exiftool -s -ee -g1 -u -n -D rose_gray.jpg---- ExifTool ----
- ExifToolVersion : 8.71
---- System ----
- FileName : rose_gray.jpg
- BitsPerSample : 8
- ColorComponents : 1
---- Composite ----
- ImageSize : 70x46
convert rose: -colorspace gray -type truecolor rose_gray.png
Fred-Weinhauss-Mac-mini:desktop fred$ exiftool -s -ee -g1 -u -n -D rose_gray.png---- ExifTool ----
- ExifToolVersion : 8.71
---- System ----
- FileName : rose_gray.png
0 ImageWidth : 70
4 ImageHeight : 46
8 BitDepth : 8
9 ColorType : 0
Re: sampling-factor always similar
Ah, I see now that GreenKoopa's test is not quite correct. However, my original point still stands. When I run
and open 3-out.jpg in GIMP, GIMP tells me the image mode is Grayscale. However, when I follow snibgo's workaround:
This seems to indicate that "-type TrueColor" is still not being fully honored the way the documentation says it should be.
Code: Select all
convert 3.jpg -type TrueColor 3-out.jpg
the resulting image looks grayscale and is reported gray by GreenKoopa's command, but opening in GIMP says that the image mode is RGB.snibgo wrote:But if the image might contain a colour, "-type" does have an effect.
For example (Windows 7, IM 6.8.5):Code: Select all
convert ^ 3.jpg ^ ( +clone -fill Red -colorize 100% ) ^ +swap -composite ^ -sampling-factor 2x2,1x1,1x1 -type Truecolor r.jpg
This seems to indicate that "-type TrueColor" is still not being fully honored the way the documentation says it should be.
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: sampling-factor always similar
I have already posted this to the Bugs forum for the IM developers review. I do not know if it matches your exact conditions. Feel free to add any further comments there. see viewtopic.php?f=3&t=24814