sampling-factor always similar

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: sampling-factor always similar

Post by anthony »

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.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
eefi
Posts: 5
Joined: 2014-01-15T16:36:58-07:00
Authentication code: 6789

Re: sampling-factor always similar

Post by eefi »

lahabana wrote:For sure here it is:
Image
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)
magick wrote:Its a bug and its already fixed. Look for a patch in ImageMagick 6.8.5-7 by sometime tomorrow. Thanks.
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.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sampling-factor always similar

Post by fmw42 »

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
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sampling-factor always similar

Post by fmw42 »

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
eefi
Posts: 5
Joined: 2014-01-15T16:36:58-07:00
Authentication code: 6789

Re: sampling-factor always similar

Post by eefi »

Ah, I see now that GreenKoopa's test is not quite correct. However, my original point still stands. When I run

Code: Select all

convert 3.jpg -type TrueColor 3-out.jpg
and open 3-out.jpg in GIMP, GIMP tells me the image mode is Grayscale. However, when I follow snibgo's workaround:
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
the resulting image looks grayscale and is reported gray by GreenKoopa's command, but opening in GIMP says that the image mode is RGB.

This seems to indicate that "-type TrueColor" is still not being fully honored the way the documentation says it should be.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: sampling-factor always similar

Post by fmw42 »

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
Post Reply