modulate convert ,why the result is not the same color?
modulate convert ,why the result is not the same color?
where is the problem?
source img:
a.png
b.png
hex to hsl convert can refer to: http://serennu.com/colour/hsltorgb.php
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: modulate convert ,why the result is not the same color?
please explain further what you are doing, especially for the third image? I am not sure how you created it. -modulate changes colors by percentages for the most part, convert creates them from scratch. You need to be sure you are working in the same color space. -modulate can use either HSL or HSB (but the default depends upon your release of IM) and you can use convert to create colors using HSL or HSB values, but you must follow the color definition rules. They are not necessarily equivalent.. Perhaps you computations are not according to how IM does -modulate. Saturation and lightness are not simple in HSL space (double hexcone). Perhaps try using HSB, where they are simpler. My guess is that your computations for H,S,L may not be correct for HSL for -modulate.
try using the percent different in S, L similar to what you have for H.
see
http://www.imagemagick.org/script/comma ... p#modulate
http://www.imagemagick.org/Usage/color_mods/#modulate
and
http://www.imagemagick.org/script/color.php
try using the percent different in S, L similar to what you have for H.
see
http://www.imagemagick.org/script/comma ... p#modulate
http://www.imagemagick.org/Usage/color_mods/#modulate
and
http://www.imagemagick.org/script/color.php
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: modulate convert ,why the result is not the same color?
your hex to hsl values are not correct for current IM syntax (since 6.5.6.6). see the colorconverter at http://www.imagemagick.org/script/color.php
#31cd84 --> hsl(151.92,156.61,127)
#31969a --> hsl(182.29,131.89,101.5)
try this for integer values of hsl:
convert -size 100x100 xc:"hsl(152,157,127)" hsl1.png
convert -size 100x100 xc:"hsl(182,132,102)" hsl2.png
L=`convert xc: -format "%[fx:100+100*(102-127)/127]" info:`
S=`convert xc: -format "%[fx:100+100*(132-157)/157]" info:`
H=`convert xc: -format "%[fx:100+200*(182-152)/360]" info:`
echo "L=$L, S=$S, H=$H"
convert hsl1.png -modulate $L,$S,$H hsl1to2.png
or for the exact hsl values that match your hex values, try this
convert -size 100x100 xc:"hsl(151.92,156.61,127)" hsl1.png
convert -size 100x100 xc:"hsl(182.29,131.89,101.5)" hsl2.png
L=`convert xc: -format "%[fx:100+100*(101.5-127)/127]" info:`
S=`convert xc: -format "%[fx:100+100*(131.89-156.61)/156.61]" info:`
H=`convert xc: -format "%[fx:100+200*(182.29-151.92)/360]" info:`
echo "L=$L, S=$S, H=$H"
convert hsl1.png -modulate $L,$S,$H hsl1to2.png
The above is unix, so if on windows, see http://www.imagemagick.org/Usage/windows/ for syntax differences
P.S. The technique/formulae seem to work for other colors:
#fedcba to #abcdef
convert -size 100x100 xc:"hsl(30,247.72,220)" hsl1.png
convert -size 100x100 xc:"hsl(210,173.4,205)" hsl2.png
L=`convert xc: -format "%[fx:100+100*(205-220)/220]" info:`
S=`convert xc: -format "%[fx:100+100*(173.4-247.72)/247.72]" info:`
H=`convert xc: -format "%[fx:100+200*(210-30)/360]" info:`
echo "L=$L, S=$S, H=$H"
convert hsl1.png -modulate $L,$S,$H hsl1to2.png
#31cd84 --> hsl(151.92,156.61,127)
#31969a --> hsl(182.29,131.89,101.5)
try this for integer values of hsl:
convert -size 100x100 xc:"hsl(152,157,127)" hsl1.png
convert -size 100x100 xc:"hsl(182,132,102)" hsl2.png
L=`convert xc: -format "%[fx:100+100*(102-127)/127]" info:`
S=`convert xc: -format "%[fx:100+100*(132-157)/157]" info:`
H=`convert xc: -format "%[fx:100+200*(182-152)/360]" info:`
echo "L=$L, S=$S, H=$H"
convert hsl1.png -modulate $L,$S,$H hsl1to2.png
or for the exact hsl values that match your hex values, try this
convert -size 100x100 xc:"hsl(151.92,156.61,127)" hsl1.png
convert -size 100x100 xc:"hsl(182.29,131.89,101.5)" hsl2.png
L=`convert xc: -format "%[fx:100+100*(101.5-127)/127]" info:`
S=`convert xc: -format "%[fx:100+100*(131.89-156.61)/156.61]" info:`
H=`convert xc: -format "%[fx:100+200*(182.29-151.92)/360]" info:`
echo "L=$L, S=$S, H=$H"
convert hsl1.png -modulate $L,$S,$H hsl1to2.png
The above is unix, so if on windows, see http://www.imagemagick.org/Usage/windows/ for syntax differences
P.S. The technique/formulae seem to work for other colors:
#fedcba to #abcdef
convert -size 100x100 xc:"hsl(30,247.72,220)" hsl1.png
convert -size 100x100 xc:"hsl(210,173.4,205)" hsl2.png
L=`convert xc: -format "%[fx:100+100*(205-220)/220]" info:`
S=`convert xc: -format "%[fx:100+100*(173.4-247.72)/247.72]" info:`
H=`convert xc: -format "%[fx:100+200*(210-30)/360]" info:`
echo "L=$L, S=$S, H=$H"
convert hsl1.png -modulate $L,$S,$H hsl1to2.png
Re: modulate convert ,why the result is not the same color?
thank you , good answer !
- fmw42
- Posts: 25562
- Joined: 2007-07-02T17:14:51-07:00
- Authentication code: 1152
- Location: Sunnyvale, California, USA
Re: modulate convert ,why the result is not the same color?
because you are adding some percent of 200 to 100. so if you have a full 360 change, you get 300 which IM says is no change. If you have a 180 change, then you get 100+100=200 which IM says is 180 rotation. If you have 0 change, then you have 100+0=100 which is no change (same as 300). All parameters at 100 are no change.
Re: modulate convert ,why the result is not the same color?
not easy to understand , but good to use . Thank you very much !
- anthony
- Posts: 8883
- Joined: 2004-05-31T19:27:03-07:00
- Authentication code: 8675308
- Location: Brisbane, Australia
Re: modulate convert ,why the result is not the same color?
Modulate is a little standard as it used a percentage to represent all values. The first two are multipliers, while the last is a addition with modulus, but 100 was always ment to mean no change. so that is how it turned out. Wierd I know.
If it was re-done it would probably be done differently, but that would destroy backward compatibility.
If it was re-done it would probably be done differently, but that would destroy backward compatibility.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
https://imagemagick.org/Usage/