Here I convert a (slightly) color image to linear grayscale, resize it, and covert back to sRGB. This works great. When I replace -resize with -distort (for the purpose of adding a rotate and crop/pad, and hopefully higher quality processing), the result is darker. Does anyone know what colorspace magick is going on here?
convert in.png -strip ^
-grayscale Rec709Luminance ^
-resize 50%% ^
-colorspace sRGB ^
-density 118.110 ^
PNG24:out_1.png
convert in.png -strip ^
-grayscale Rec709Luminance ^
-virtual-pixel white -set option:distort:viewport 3300x5100+1925+2780 ^
-distort SRT "0.5 0.12" +repage ^
-colorspace sRGB ^
-density 118.110 ^
PNG24:out_2.png
Usage Example: Resizing with Colorspace Correction
This is the concept I was aiming for, but with grayscale conversion. It mentions -distort as handling colorspace the same as does -resize.
http://www.imagemagick.org/Usage/resize ... colorspace
Test Image:
https://googledrive.com/host/0Bxw3ymi4d ... bXc/in.png
ImageMagick-7.0.1-9-portable-Q16-x64.zip
Version: ImageMagick 7.0.1-9 Q16 x64 2016-06-03
Features: Cipher DPC HDRI
Windows 7 64-bit
-resize vs -distort, a colorspace problem?
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -resize vs -distort, a colorspace problem?
The problem seems to be:
It seems that "-distort SRT" is changing the gamma setting, so the conversion back to sRGB does nothing.
Looks like a bug (in v7) to me.
Code: Select all
f:\web\im>%IMG7%magick -size 1x100 gradient: -grayscale Rec709Luminance -resize 50% -verbose info: |findstr Gamma
Gamma: 1
f:\web\im>%IMG7%magick -size 1x100 gradient: -grayscale Rec709Luminance -distort SRT "0.5,1" -verbose info: |findstr Gamma
Gamma: 0.454545
Looks like a bug (in v7) to me.
snibgo's IM pages: im.snibgo.com
-
- Posts: 12159
- Joined: 2010-01-23T23:01:33-07:00
- Authentication code: 1151
- Location: England, UK
Re: -resize vs -distort, a colorspace problem?
I've reported this as a bug: viewtopic.php?f=3&t=29896
snibgo's IM pages: im.snibgo.com
- GreenKoopa
- Posts: 457
- Joined: 2010-11-04T17:24:08-07:00
- Authentication code: 8675308
Re: -resize vs -distort, a colorspace problem?
Thank you snibgo for clarifying the issue. Reading through the info:, it appears that -distort also changes the colorspace.
Adding "-set colorspace RGB" after the -distort works around this problem. Interestingly, so does adding it before the -distort. It appears that distort is okay with gamma=1 but not colorspace=gray.
Adding "-set colorspace RGB" after the -distort works around this problem. Interestingly, so does adding it before the -distort. It appears that distort is okay with gamma=1 but not colorspace=gray.