Image Resize is ignoring Gamma
Posted: 2018-10-01T23:53:06-07:00
I have a picture with an unusually low Gamma value that I am trying to resize. The command I am using:
convert /tmp/in.png -colorspace RGB -resize 160x160 -colorspace sRGB /tmp/out.png
Normally PNG files have a Gamma of about .45, but this image has a Gamma of 0.02. I tried to compensate for this by doing the RGB colorspace conversion and then convert back to sRGB before saving, but this does not work. I would upload the image itself, but there isn't a way to upload to this forum.
The correct output, due to the Gamma correction, should be much darker than the produced image.
Here is the output of identify:
convert /tmp/in.png -colorspace RGB -resize 160x160 -colorspace sRGB /tmp/out.png
Normally PNG files have a Gamma of about .45, but this image has a Gamma of 0.02. I tried to compensate for this by doing the RGB colorspace conversion and then convert back to sRGB before saving, but this does not work. I would upload the image itself, but there isn't a way to upload to this forum.
The correct output, due to the Gamma correction, should be much darker than the produced image.
Here is the output of identify:
Code: Select all
$ identify -verbose /tmp/in.png
Image: /tmp/in.png
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: DirectClass
Geometry: 561x265+0+0
Units: Undefined
Type: TrueColor
Endianess: Undefined
Colorspace: sRGB
Depth: 8-bit
Channel depth:
red: 8-bit
green: 8-bit
blue: 8-bit
Channel statistics:
Pixels: 148665
Red:
min: 0 (0)
max: 255 (1)
mean: 163.948 (0.642932)
standard deviation: 76.6095 (0.300429)
kurtosis: -1.28908
skewness: -0.410074
Green:
min: 4 (0.0156863)
max: 255 (1)
mean: 149.554 (0.586487)
standard deviation: 78.1692 (0.306546)
kurtosis: -1.43049
skewness: -0.084559
Blue:
min: 0 (0)
max: 255 (1)
mean: 106.007 (0.415715)
standard deviation: 95.4505 (0.374316)
kurtosis: -1.59065
skewness: 0.472043
Image statistics:
Overall:
min: 0 (0)
max: 255 (1)
mean: 139.836 (0.548378)
standard deviation: 83.8456 (0.328806)
kurtosis: -1.32889
skewness: -0.0904844
Rendering intent: Perceptual
Gamma: 0.02
Chromaticity:
red primary: (0.64,0.33)
green primary: (0.3,0.6)
blue primary: (0.15,0.06)
white point: (0.3127,0.329)
Background color: white
Border color: srgb(223,223,223)
Matte color: grey74
Transparent color: black
Interlace: None
Intensity: Undefined
Compose: Over
Page geometry: 561x265+0+0
Dispose: Undefined
Iterations: 0
Compression: Zip
Orientation: Undefined
Properties:
date:create: 2018-10-01T23:48:21-07:00
date:modify: 2018-10-01T23:48:21-07:00
png:gAMA: gamma=0.02 (See Gamma, above)
png:IHDR.bit-depth-orig: 8
png:IHDR.bit_depth: 8
png:IHDR.color-type-orig: 2
png:IHDR.color_type: 2 (Truecolor)
png:IHDR.interlace_method: 0 (Not interlaced)
png:IHDR.width,height: 561, 265
signature: 83f5acaa2aaaf00f14232885a0362090aada8358979382579ce27b7788b4a708
Artifacts:
filename: /tmp/in.png
verbose: true
Tainted: False
Filesize: 315KB
Number pixels: 149K
Pixels per second: 14.87MB
User time: 0.010u
Elapsed time: 0:01.010
Version: ImageMagick 6.8.9-9 Q16 x86_64 2018-07-10 http://www.imagemagick.org