Page 1 of 1

Greyscale half of image diagonally solution tips? Using rmagick

Posted: 2016-01-07T17:25:58-07:00
by gilbert
https://i.imgur.com/FRqephU.jpg

Any tips on achieving this output?

Re: Greyscale half of image diagonally solution tips? Using rmagick

Posted: 2016-01-07T17:40:02-07:00
by fmw42
I do not know RMagick, but perhaps you can convert from the following command lines. I had to crop out your input image. It would be best in the future if you provide two separate images. Also always provide your IM version and platform. See viewtopic.php?f=1&t=9620

Code: Select all

size=`convert FRqephU.png -format "%wx%h" info:`
ww=`echo $size | cut -dx -f1`
hh=`echo $size | cut -dx -f2`
p1=0,0
p2="$((ww-1)),0"
p3="0,$((hh-1))"
echo "p1=$p1; p2=$p2; p3=$p3;"
convert FRqephU.png \
\( -clone 0 -colorspace gray \) \
\( -clone 0 -fill black -colorize 100 \
-fill white -draw "polygon $p1 $p2 $p3" \) \
-alpha off -compose over -composite result.png

Re: Greyscale half of image diagonally solution tips? Using rmagick

Posted: 2016-01-07T22:09:46-07:00
by gilbert
Thanks so much. That's pretty close to what I need; it's just coming out a bit dark. How would I go about making the result lighter?

https://imgur.com/a/n4LgP - here's an album (original, expected, actual).

I really appreciate the help. Are you Fred?

Re: Greyscale half of image diagonally solution tips? Using rmagick

Posted: 2016-01-07T22:21:26-07:00
by fmw42
Yes, Fred here.

What version of Imagemagick and what platform are you using? Please always provide that information since syntax and IM may work differently. see viewtopic.php?f=1&t=9620

Your problem may be due to older versions of IM using linear grayscale rather than sRGB or when RGB and sRGB were reversed.

Since I do not know what version of IM you are using try one of the following:

Code: Select all

size=`convert FRqephU.png -format "%wx%h" info:`
ww=`echo $size | cut -dx -f1`
hh=`echo $size | cut -dx -f2`
p1=0,0
p2="$((ww-1)),0"
p3="0,$((hh-1))"
echo "p1=$p1; p2=$p2; p3=$p3;"
convert FRqephU.png \
\( -clone 0 -set colorspace RGB -colorspace gray \) \
\( -clone 0 -fill black -colorize 100 \
-fill white -draw "polygon $p1 $p2 $p3" \) \
-alpha off -compose over -composite result.png

Code: Select all

size=`convert FRqephU.png -format "%wx%h" info:`
ww=`echo $size | cut -dx -f1`
hh=`echo $size | cut -dx -f2`
p1=0,0
p2="$((ww-1)),0"
p3="0,$((hh-1))"
echo "p1=$p1; p2=$p2; p3=$p3;"
convert FRqephU.png \
\( -clone 0 -set colorspace sRGB -colorspace gray \) \
\( -clone 0 -fill black -colorize 100 \
-fill white -draw "polygon $p1 $p2 $p3" \) \
-alpha off -compose over -composite result.png

Code: Select all

size=`convert FRqephU.png -format "%wx%h" info:`
ww=`echo $size | cut -dx -f1`
hh=`echo $size | cut -dx -f2`
p1=0,0
p2="$((ww-1)),0"
p3="0,$((hh-1))"
echo "p1=$p1; p2=$p2; p3=$p3;"
convert FRqephU.png \
\( -clone 0 -grayscale Rec709Luminance \) \
\( -clone 0 -fill black -colorize 100 \
-fill white -draw "polygon $p1 $p2 $p3" \) \
-alpha off -compose over -composite result.png

Code: Select all

size=`convert FRqephU.png -format "%wx%h" info:`
ww=`echo $size | cut -dx -f1`
hh=`echo $size | cut -dx -f2`
p1=0,0
p2="$((ww-1)),0"
p3="0,$((hh-1))"
echo "p1=$p1; p2=$p2; p3=$p3;"
convert FRqephU.png \
\( -clone 0 -grayscale Rec601Luminance \) \
\( -clone 0 -fill black -colorize 100 \
-fill white -draw "polygon $p1 $p2 $p3" \) \
-alpha off -compose over -composite result.png

see viewtopic.php?f=4&t=21269 and http://www.imagemagick.org/script/comma ... #grayscale and http://www.imagemagick.org/script/comma ... #intensity

If none of the above work, then it could be a profile issue. But I won't look into that until I hear back from you.