Page 2 of 2

Re: Getting pixels from a grayscale PSD with alpha

Posted: 2017-06-15T13:51:59-07:00
by fmw42
In case it had to do with 16-bit per channel from Q16, I will try again at 8-bits per channel

Code: Select all

convert -size 128x128 gradient: -alpha copy -depth 8 test.psd
convert test.psd -format "%[pixel:u.p{20,20}]\n" info:
graya(215,1)
graya(215,1)

Code: Select all

convert -size 128x128 gradient: -alpha copy -depth 8 test.psd
convert test.psd -format "%[pixel:u.p{100,100}]\n" info:
graya(54,1)
graya(54,1)


Still the same issue. But viewing the PSD file in Mac GraphicConverter, shows the alpha channel reversed in polarity, though it is not fully opaque.

So even -format "%[pixel:u.p{20,20}]\n" in command line is not reading the pixel values from the PSD file correctly.

Re: Getting pixels from a grayscale PSD with alpha

Posted: 2017-06-15T14:00:38-07:00
by fmw42
I do not know that IM can convert a grayscale PSD to truecolor.

Code: Select all

convert -size 128x128 gradient: -alpha copy -depth 8 -define colorspace:auto-grayscale=off -type truecoloralpha test.psd
convert test.psd -format "%[pixel:u.p{100,100}]\n" info:
graya(54,1)
graya(54,1)

Result is still the same

Re: Getting pixels from a grayscale PSD with alpha

Posted: 2017-06-15T14:08:30-07:00
by fmw42
GIMP displays the PSD file the same as GraphicConverter with inverted alpha values. But it also complains

"Calling error for procedure 'gimp-image-set-resolution': Image resolution is out of bounds, using the default resolution in stead"

Perhaps because I did not set a density or units?

Re: Getting pixels from a grayscale PSD with alpha

Posted: 2017-06-15T14:08:40-07:00
by dlemstra
valen wrote: 2017-06-15T08:02:54-07:00 The first image (grayscale, no alpha) prints out 512 pixel values. This is because ImageMagick reads 2 channels from it. Why 2? I don't know. All the values it prints out are 35. I assume this is a gamma adjusted value based on the original 50 we used.
You have 2 channels. One is the value of the red channel (RedPixelChannel) and the other value is (IndexPixelChannel). To know which value is which you should call the .offset method of the Pixels class. I am guessing that the colormap that is created contains values where the index has the same value as it's value.
valen wrote: 2017-06-15T08:02:54-07:00 The second image (grayscale, yes alpha) prints out 768 pixel values. This is because ImageMagick reads 3 channels from it. Why 3? I don't know. The values print out in a repeating pattern "186, 255, 186". Over and over again until all 768 are printed, that pattern repeats. I assume the 186 is a gamma adjusted value based on the original 200 we used. I don't know where the 255 came from. And notice the actual grayscale values of 50 (or adjusted 35) are nowhere to be found!!!??
You have 3 channels. One is the value of the red channel (RedPixelChannel), one is the alpha channel (AlphaPixelChannel) and the other value is (IndexPixelChannel). To know which value is which you should call the .offset method of the Pixels class. The 255 value is the value of the alpha channel. And I think you are not getting 35 because the alpha is blended into the red channel. This would explain why the alpha channel is fully opaque.