Debian Codegraph @

tests/cli-heic.tap

raw
1 #!/bin/sh
2 #
3 # Copyright 1999 ImageMagick Studio LLC, a non-profit organization
4 # dedicated to making software imaging solutions freely available.
5 #
6 # You may not use this file except in compliance with the License. You may
7 # obtain a copy of the License at
8 #
9 # https://imagemagick.org/license/
10 #
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.
16 #
17 . ./common.shi
18 . ${srcdir}/tests/common.shi
19
20 source=heic_cicp_source.avif
21 resized=heic_cicp_resized.avif
22 explicit_cicp=heic_cicp_explicit.avif
23 explicit_clli=heic_clli_explicit.avif
24 no_cicp=heic_cicp_disabled.avif
25 no_clli=heic_clli_disabled.avif
26 invalid_clli=heic_clli_invalid.avif
27 malformed_clli=heic_clli_malformed.avif
28 identity_source=heic_identity_cicp_source.avif
29 identity_resized=heic_identity_cicp_resized.avif
30 identity_explicit_chroma=heic_identity_cicp_chroma.avif
31 identity_chroma_420=heic_identity_cicp_420.avif
32 identity_chroma_422=heic_identity_cicp_422.avif
33 identity_explicit_conflict=heic_identity_cicp_conflict.avif
34 identity_no_cicp=heic_identity_cicp_disabled.avif
35
36 cleanup()
37 {
38 rm -f "$source" "$resized" "$explicit_cicp" "$explicit_clli" \
39 "$no_cicp" "$no_clli" "$invalid_clli" "$malformed_clli" \
40 "$identity_source" "$identity_resized" "$identity_explicit_chroma" \
41 "$identity_chroma_420" "$identity_chroma_422" \
42 "$identity_explicit_conflict" "$identity_no_cicp"
43 }
44
45 check_property()
46 {
47 actual=`${IDENTIFY} -quiet -format "$2" "$1" 2>/dev/null`
48 if [ $? -ne 0 ]; then
49 echo "not ok"
50 echo "# identify failed for '$1'"
51 elif [ "X$actual" = "X$3" ]; then
52 echo "ok"
53 else
54 echo "not ok"
55 echo "# expected '$3', got '$actual'"
56 fi
57 }
58
59 cleanup
60 if ! ${MAGICK} -size 4x4 gradient:red-blue -depth 10 \
61 -define heic:cicp=12/16/6/1 -define heic:clli=1624,182 \
62 "$source" >/dev/null 2>&1; then
63 echo "1..0 # SKIP AVIF coder unavailable"
64 exit 0
65 fi
66
67 metadata=`${IDENTIFY} -quiet -format '%[heic:cicp] %[heic:clli]' \
68 "$source" 2>/dev/null`
69 if [ "X$metadata" != "X12/16/6/1 1624,182" ]; then
70 echo "1..0 # SKIP HEIC CICP/CLLI unsupported by libheif delegate"
71 cleanup
72 exit 0
73 fi
74
75 identity_cicp_supported=false
76 if ${MAGICK} -size 4x4 gradient:red-blue -depth 10 \
77 -define heic:cicp=1/13/0/1 -define heic:chroma=444 \
78 "$identity_source" >/dev/null 2>&1; then
79 identity_metadata=`${IDENTIFY} -quiet -format '%[heic:cicp]' \
80 "$identity_source" 2>/dev/null`
81 if [ "X$identity_metadata" = "X1/13/0/1" ]; then
82 identity_cicp_supported=true
83 fi
84 fi
85
86 echo "1..14"
87
88 check_property "$source" '%[heic:cicp] %[heic:clli]' '12/16/6/1 1624,182'
89
90 ${MAGICK} "$source" -resize 50% "$resized" >/dev/null 2>&1 &&
91 check_property "$resized" '%[heic:cicp] %[heic:clli]' \
92 '12/16/6/1 1624,182' || echo "not ok"
93
94 ${MAGICK} "$source" -resize 50% -define heic:cicp=1/13/6/1 \
95 "$explicit_cicp" >/dev/null 2>&1 &&
96 check_property "$explicit_cicp" '%[heic:cicp] %[heic:clli]' \
97 '1/13/6/1 1624,182' || echo "not ok"
98
99 ${MAGICK} "$source" -resize 50% -define heic:clli='1000, 200' \
100 "$explicit_clli" >/dev/null 2>&1 &&
101 check_property "$explicit_clli" '%[heic:cicp] %[heic:clli]' \
102 '12/16/6/1 1000,200' || echo "not ok"
103
104 ${MAGICK} "$source" -resize 50% -define heic:preserve-cicp=false \
105 "$no_cicp" >/dev/null 2>&1 &&
106 check_property "$no_cicp" '%[heic:cicp]' '' || echo "not ok"
107
108 ${MAGICK} "$source" -resize 50% -define heic:preserve-clli=false \
109 "$no_clli" >/dev/null 2>&1 &&
110 check_property "$no_clli" '%[heic:cicp] %[heic:clli]' '12/16/6/1 ' ||
111 echo "not ok"
112
113 if ${MAGICK} "$source" -define heic:clli=70000,200 "$invalid_clli" \
114 >/dev/null 2>&1; then
115 echo "not ok"
116 else
117 echo "ok"
118 fi
119
120 if ${MAGICK} "$source" -define heic:clli=1000,200x "$malformed_clli" \
121 >/dev/null 2>&1; then
122 echo "not ok"
123 else
124 echo "ok"
125 fi
126
127 if [ "X$identity_cicp_supported" = "Xtrue" ]; then
128 ${MAGICK} "$identity_source" -resize 50% "$identity_resized" \
129 >/dev/null 2>&1 &&
130 check_property "$identity_resized" '%[heic:cicp]' '1/13/0/1' ||
131 echo "not ok"
132
133 ${MAGICK} "$identity_source" -resize 50% -define heic:chroma=444 \
134 "$identity_explicit_chroma" >/dev/null 2>&1 &&
135 check_property "$identity_explicit_chroma" '%[heic:cicp]' '1/13/0/1' ||
136 echo "not ok"
137
138 ${MAGICK} "$identity_source" -resize 50% -define heic:chroma=420 \
139 "$identity_chroma_420" >/dev/null 2>&1 &&
140 check_property "$identity_chroma_420" '%[heic:cicp]' '1/13/6/1' ||
141 echo "not ok"
142
143 ${MAGICK} "$identity_source" -resize 50% -define heic:chroma=422 \
144 "$identity_chroma_422" >/dev/null 2>&1 &&
145 check_property "$identity_chroma_422" '%[heic:cicp]' '1/13/6/1' ||
146 echo "not ok"
147
148 if ${MAGICK} "$identity_source" -resize 50% -define heic:cicp=1/13/0/1 \
149 -define heic:chroma=420 "$identity_explicit_conflict" \
150 >/dev/null 2>&1; then
151 echo "not ok"
152 else
153 echo "ok"
154 fi
155
156 ${MAGICK} "$identity_source" -resize 50% -define heic:preserve-cicp=false \
157 -define heic:chroma=420 "$identity_no_cicp" >/dev/null 2>&1 &&
158 check_property "$identity_no_cicp" '%[heic:cicp]' '' || echo "not ok"
159 else
160 echo "ok # SKIP HEIC identity matrix CICP unsupported by libheif delegate"
161 echo "ok # SKIP HEIC identity matrix CICP unsupported by libheif delegate"
162 echo "ok # SKIP HEIC identity matrix CICP unsupported by libheif delegate"
163 echo "ok # SKIP HEIC identity matrix CICP unsupported by libheif delegate"
164 echo "ok # SKIP HEIC identity matrix CICP unsupported by libheif delegate"
165 echo "ok # SKIP HEIC identity matrix CICP unsupported by libheif delegate"
166 fi
167
168 cleanup
169 :