3 # Copyright 1999-2013 ImageMagick Studio LLC, a non-profit organization
4 # dedicated to making software imaging solutions freely available.
6 # You may not use this file except in compliance with the License. You may
7 # obtain a copy of the License at
9 # http://www.imagemagick.org/script/license.php
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
17 . ${srcdir}/tests/common.shi
19 depth=`eval ${MAGICK} xc:none -format '%[fx:QuantumRange]' info:-`
20 if [ "X$depth" == "X255" ]; then
27 # how to generate a one pixel (average rose) color and output its values
28 in="rose: -scale 1x1" # a one pixel image of the average color.
29 out="-format '%[fx:int(255*r+.5)],%[fx:int(255*g+.5)],%[fx:int(255*b+.5)]' info:-"
33 # Colors to compare results to.
35 average=`eval ${MAGICK} "$in" -noop "$out"`
36 too_dark=`eval ${MAGICK} "$in" -colorspace RGB "$out"`
37 too_light=`eval ${MAGICK} "$in" -set colorspace RGB -colorspace sRGB "$out"`
38 format='%-30s%s\n' # results formating
39 format2='%-30s%-14s%s\n'
41 printf "$format2" "Average \"rose:\" Color" "$average" "sRGB(rose)"
42 printf "$format2" "Too Dark Color" "$too_dark" "sRGB(rose)->RGB result"
43 printf "$format2" "Too Light Color" "$too_light" "RGB(rose)->sRGB result"
49 # NOTE: as a extra validation on sanity checks below...
50 # eval ${MAGICK} "$in" -gamma .454545 "$out"
51 # produces a value of 74,25,20 which is close to 73,26,21 below.
52 # eval ${MAGICK} "$in" -gamma 2.2 "$out"
53 # produces a value of 198,158,151 whcih is close to 199,160,152 below.
55 # Actual values used below come from IM v6.5.4-7 colorspace conversions
58 if [ "X$average" != "X146,89,80" ]; then
59 echo "Sanity Failure: Average expected to be 145,89,80 - ABORTING"
62 if [ "X$too_dark" != "X73,26,21" ]; then
63 echo "Sanity Failure: Too Dark expected to be 73,26,21 - ABORTING"
66 if [ "X$too_light" != "X199,160,152" ]; then
67 echo "Sanity Failure: Too Light expected to be 199,160,152 - ABORTING"
76 test="${test}->$i" # format of the test being performed
77 cs="$cs -colorspace $i" # colorspace operations to perform test
79 color=`eval ${MAGICK} "$in" $cs "$out"`
81 if [ "X$color" = "X$average" ]; then
84 # Its failed the round-trip test, now report how it failed!
86 if [ "X$color" = "X$too_light" ]; then
89 if [ "X$color" = "X$too_dark" ]; then
97 test_color RGB sRGB && echo "ok" || echo "not ok"
99 test_color XYZ sRGB && echo "ok" || echo "not ok"
100 test_color XYZ RGB sRGB && echo "ok" || echo "not ok"
101 test_color RGB XYZ sRGB && echo "ok" || echo "not ok"
103 test_color LAB sRGB && echo "ok" || echo "not ok"
104 test_color XYZ LAB sRGB && echo "ok" || echo "not ok"
105 test_color LAB XYZ sRGB && echo "ok" || echo "not ok"
106 test_color RGB LAB sRGB && echo "ok" || echo "not ok"
107 test_color LAB RGB sRGB && echo "ok" || echo "not ok"
109 test_color CMY sRGB && echo "ok" || echo "not ok"
110 test_color CMYK sRGB && echo "ok" || echo "not ok"
111 test_color HSL sRGB && echo "ok" || echo "not ok"
112 test_color HSB sRGB && echo "ok" || echo "not ok"
113 test_color HWB sRGB && echo "ok" || echo "not ok"
114 test_color Log sRGB && echo "ok" || echo "not ok"
115 test_color YIQ sRGB && echo "ok" || echo "not ok"
116 test_color YUV sRGB && echo "ok" || echo "not ok"
117 test_color YCbCr sRGB && echo "ok" || echo "not ok"
118 test_color OHTA sRGB && echo "ok" || echo "not ok"