Difference between -colorspace and -set colorspace with PNG
Posted: 2013-10-15T10:14:35-07:00
I am a bit puzzled about the difference between the use of -colorspace RGB and -set colorspace RGB on a linear (gamma=1) grayscale image. Using -set colorspace RGB does not change the data nor gamma=1, but -colorspace seems to change the data, but leaves gamma=1.
Can someone explain why the difference? I would have expected -colorspace RGB to make no changes since the image was already linear grayscale? Is the current result correct? If so, why the change? At most I would have thought it would only change the colorspace to RGB and not change the data.
# create linear (gamma=1) grayscale image
imbh convert rose: -colorspace sRGB -grayscale rec709luminance rose_luminance.png
# apply -set colorspace (is exactly the same as above as expected)
imbh convert rose_luminance.png -set colorspace RGB rose_luminance_2.png
# apply -colorspace RGB (the min,max,mean,std and number of colors has changed)
imbh convert rose_luminance.png -colorspace RGB rose_luminance_1.png
Can someone explain why the difference? I would have expected -colorspace RGB to make no changes since the image was already linear grayscale? Is the current result correct? If so, why the change? At most I would have thought it would only change the colorspace to RGB and not change the data.
# create linear (gamma=1) grayscale image
imbh convert rose: -colorspace sRGB -grayscale rec709luminance rose_luminance.png
Code: Select all
Image: rose_luminance.png
Geometry: 70x46+0+0
Page geometry: 70x46+0+0
Class: PseudoClass
Colorspace: Gray
Type: Grayscale
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
Colors: 200
Gray:
min: 5 (0.0196078)
max: 255 (1)
mean: 49.9761 (0.195985)
standard deviation: 53.9087 (0.211407)
# apply -set colorspace (is exactly the same as above as expected)
imbh convert rose_luminance.png -set colorspace RGB rose_luminance_2.png
Code: Select all
Image: rose_luminance_2.png
Geometry: 70x46+0+0
Page geometry: 70x46+0+0
Class: PseudoClass
Colorspace: Gray
Type: Grayscale
Depth: 8/1-bit
Alpha: False
Channels: gray
Rendering intent: Undefined
Gamma: 1
Colors: 200
Gray:
min: 5 (0.0196078)
max: 255 (1)
mean: 49.9761 (0.195985)
standard deviation: 53.9087 (0.211407)
# apply -colorspace RGB (the min,max,mean,std and number of colors has changed)
imbh convert rose_luminance.png -colorspace RGB rose_luminance_1.png
Code: Select all
Image: rose_luminance_1.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: PseudoClass
Geometry: 70x46+0+0
Units: Undefined
Type: Grayscale
Endianess: Undefined
Colorspace: Gray
Depth: 8/1-bit
Channel depth:
gray: 8-bit
Channel statistics:
Gray:
min: 0 (0)
max: 255 (1)
mean: 19.8901 (0.0780002)
standard deviation: 52.26 (0.204941)
kurtosis: 12.7353
skewness: 3.72498
Colors: 134
Histogram:
...
Colormap entries: 256
Colormap:
...
Rendering intent: Undefined
Gamma: 1
...
Properties:
date:create: 2013-10-15T09:49:07-07:00
date:modify: 2013-10-15T09:49:07-07:00
png:bKGD: chunk was found (see Background color, above)
png:gAMA: gamma=1 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 0
png:IHDR.color_type: 0 (Grayscale)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 70, 46
png:text: 2 tEXt/zTXt/iTXt chunks were found
signature: 6c40361a5da66526ad84d455db2743f96ce3d551608fc16d9f7ef75030e83eac