@@ -43,107 +43,158 @@ def test_wrong_args(self):
4343 im = Image .new ("RGB" , (10 , 10 ), 0 )
4444
4545 with pytest .raises (ValueError , match = "filter" ):
46- im .im .color_lut_3d ("RGB" , Image .CUBIC , * self .generate_identity_table (3 , 3 ))
46+ im .im .color_lut_3d (
47+ "RGB" , Image .Resampling .BICUBIC , * self .generate_identity_table (3 , 3 )
48+ )
4749
4850 with pytest .raises (ValueError , match = "image mode" ):
4951 im .im .color_lut_3d (
50- "wrong" , Image .LINEAR , * self .generate_identity_table (3 , 3 )
52+ "wrong" , Image .Resampling . BILINEAR , * self .generate_identity_table (3 , 3 )
5153 )
5254
5355 with pytest .raises (ValueError , match = "table_channels" ):
54- im .im .color_lut_3d ("RGB" , Image .LINEAR , * self .generate_identity_table (5 , 3 ))
56+ im .im .color_lut_3d (
57+ "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (5 , 3 )
58+ )
5559
5660 with pytest .raises (ValueError , match = "table_channels" ):
57- im .im .color_lut_3d ("RGB" , Image .LINEAR , * self .generate_identity_table (1 , 3 ))
61+ im .im .color_lut_3d (
62+ "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (1 , 3 )
63+ )
5864
5965 with pytest .raises (ValueError , match = "table_channels" ):
60- im .im .color_lut_3d ("RGB" , Image .LINEAR , * self .generate_identity_table (2 , 3 ))
66+ im .im .color_lut_3d (
67+ "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (2 , 3 )
68+ )
6169
6270 with pytest .raises (ValueError , match = "Table size" ):
6371 im .im .color_lut_3d (
64- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (1 , 3 , 3 ))
72+ "RGB" ,
73+ Image .Resampling .BILINEAR ,
74+ * self .generate_identity_table (3 , (1 , 3 , 3 )),
6575 )
6676
6777 with pytest .raises (ValueError , match = "Table size" ):
6878 im .im .color_lut_3d (
69- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (66 , 3 , 3 ))
79+ "RGB" ,
80+ Image .Resampling .BILINEAR ,
81+ * self .generate_identity_table (3 , (66 , 3 , 3 )),
7082 )
7183
7284 with pytest .raises (ValueError , match = r"size1D \* size2D \* size3D" ):
73- im .im .color_lut_3d ("RGB" , Image .LINEAR , 3 , 2 , 2 , 2 , [0 , 0 , 0 ] * 7 )
85+ im .im .color_lut_3d (
86+ "RGB" , Image .Resampling .BILINEAR , 3 , 2 , 2 , 2 , [0 , 0 , 0 ] * 7
87+ )
7488
7589 with pytest .raises (ValueError , match = r"size1D \* size2D \* size3D" ):
76- im .im .color_lut_3d ("RGB" , Image .LINEAR , 3 , 2 , 2 , 2 , [0 , 0 , 0 ] * 9 )
90+ im .im .color_lut_3d (
91+ "RGB" , Image .Resampling .BILINEAR , 3 , 2 , 2 , 2 , [0 , 0 , 0 ] * 9
92+ )
7793
7894 with pytest .raises (TypeError ):
79- im .im .color_lut_3d ("RGB" , Image .LINEAR , 3 , 2 , 2 , 2 , [0 , 0 , "0" ] * 8 )
95+ im .im .color_lut_3d (
96+ "RGB" , Image .Resampling .BILINEAR , 3 , 2 , 2 , 2 , [0 , 0 , "0" ] * 8
97+ )
8098
8199 with pytest .raises (TypeError ):
82- im .im .color_lut_3d ("RGB" , Image .LINEAR , 3 , 2 , 2 , 2 , 16 )
100+ im .im .color_lut_3d ("RGB" , Image .Resampling . BILINEAR , 3 , 2 , 2 , 2 , 16 )
83101
84102 def test_correct_args (self ):
85103 im = Image .new ("RGB" , (10 , 10 ), 0 )
86104
87- im .im .color_lut_3d ("RGB" , Image .LINEAR , * self .generate_identity_table (3 , 3 ))
105+ im .im .color_lut_3d (
106+ "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
107+ )
88108
89- im .im .color_lut_3d ("CMYK" , Image .LINEAR , * self .generate_identity_table (4 , 3 ))
109+ im .im .color_lut_3d (
110+ "CMYK" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
111+ )
90112
91113 im .im .color_lut_3d (
92- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (2 , 3 , 3 ))
114+ "RGB" ,
115+ Image .Resampling .BILINEAR ,
116+ * self .generate_identity_table (3 , (2 , 3 , 3 )),
93117 )
94118
95119 im .im .color_lut_3d (
96- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (65 , 3 , 3 ))
120+ "RGB" ,
121+ Image .Resampling .BILINEAR ,
122+ * self .generate_identity_table (3 , (65 , 3 , 3 )),
97123 )
98124
99125 im .im .color_lut_3d (
100- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (3 , 65 , 3 ))
126+ "RGB" ,
127+ Image .Resampling .BILINEAR ,
128+ * self .generate_identity_table (3 , (3 , 65 , 3 )),
101129 )
102130
103131 im .im .color_lut_3d (
104- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (3 , 3 , 65 ))
132+ "RGB" ,
133+ Image .Resampling .BILINEAR ,
134+ * self .generate_identity_table (3 , (3 , 3 , 65 )),
105135 )
106136
107137 def test_wrong_mode (self ):
108138 with pytest .raises (ValueError , match = "wrong mode" ):
109139 im = Image .new ("L" , (10 , 10 ), 0 )
110- im .im .color_lut_3d ("RGB" , Image .LINEAR , * self .generate_identity_table (3 , 3 ))
140+ im .im .color_lut_3d (
141+ "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
142+ )
111143
112144 with pytest .raises (ValueError , match = "wrong mode" ):
113145 im = Image .new ("RGB" , (10 , 10 ), 0 )
114- im .im .color_lut_3d ("L" , Image .LINEAR , * self .generate_identity_table (3 , 3 ))
146+ im .im .color_lut_3d (
147+ "L" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
148+ )
115149
116150 with pytest .raises (ValueError , match = "wrong mode" ):
117151 im = Image .new ("L" , (10 , 10 ), 0 )
118- im .im .color_lut_3d ("L" , Image .LINEAR , * self .generate_identity_table (3 , 3 ))
152+ im .im .color_lut_3d (
153+ "L" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
154+ )
119155
120156 with pytest .raises (ValueError , match = "wrong mode" ):
121157 im = Image .new ("RGB" , (10 , 10 ), 0 )
122158 im .im .color_lut_3d (
123- "RGBA" , Image .LINEAR , * self .generate_identity_table (3 , 3 )
159+ "RGBA" , Image .Resampling . BILINEAR , * self .generate_identity_table (3 , 3 )
124160 )
125161
126162 with pytest .raises (ValueError , match = "wrong mode" ):
127163 im = Image .new ("RGB" , (10 , 10 ), 0 )
128- im .im .color_lut_3d ("RGB" , Image .LINEAR , * self .generate_identity_table (4 , 3 ))
164+ im .im .color_lut_3d (
165+ "RGB" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
166+ )
129167
130168 def test_correct_mode (self ):
131169 im = Image .new ("RGBA" , (10 , 10 ), 0 )
132- im .im .color_lut_3d ("RGBA" , Image .LINEAR , * self .generate_identity_table (3 , 3 ))
170+ im .im .color_lut_3d (
171+ "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
172+ )
133173
134174 im = Image .new ("RGBA" , (10 , 10 ), 0 )
135- im .im .color_lut_3d ("RGBA" , Image .LINEAR , * self .generate_identity_table (4 , 3 ))
175+ im .im .color_lut_3d (
176+ "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
177+ )
136178
137179 im = Image .new ("RGB" , (10 , 10 ), 0 )
138- im .im .color_lut_3d ("HSV" , Image .LINEAR , * self .generate_identity_table (3 , 3 ))
180+ im .im .color_lut_3d (
181+ "HSV" , Image .Resampling .BILINEAR , * self .generate_identity_table (3 , 3 )
182+ )
139183
140184 im = Image .new ("RGB" , (10 , 10 ), 0 )
141- im .im .color_lut_3d ("RGBA" , Image .LINEAR , * self .generate_identity_table (4 , 3 ))
185+ im .im .color_lut_3d (
186+ "RGBA" , Image .Resampling .BILINEAR , * self .generate_identity_table (4 , 3 )
187+ )
142188
143189 def test_identities (self ):
144190 g = Image .linear_gradient ("L" )
145191 im = Image .merge (
146- "RGB" , [g , g .transpose (Image .ROTATE_90 ), g .transpose (Image .ROTATE_180 )]
192+ "RGB" ,
193+ [
194+ g ,
195+ g .transpose (Image .Transpose .ROTATE_90 ),
196+ g .transpose (Image .Transpose .ROTATE_180 ),
197+ ],
147198 )
148199
149200 # Fast test with small cubes
@@ -152,7 +203,9 @@ def test_identities(self):
152203 im ,
153204 im ._new (
154205 im .im .color_lut_3d (
155- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , size )
206+ "RGB" ,
207+ Image .Resampling .BILINEAR ,
208+ * self .generate_identity_table (3 , size ),
156209 )
157210 ),
158211 )
@@ -162,23 +215,32 @@ def test_identities(self):
162215 im ,
163216 im ._new (
164217 im .im .color_lut_3d (
165- "RGB" , Image .LINEAR , * self .generate_identity_table (3 , (2 , 2 , 65 ))
218+ "RGB" ,
219+ Image .Resampling .BILINEAR ,
220+ * self .generate_identity_table (3 , (2 , 2 , 65 )),
166221 )
167222 ),
168223 )
169224
170225 def test_identities_4_channels (self ):
171226 g = Image .linear_gradient ("L" )
172227 im = Image .merge (
173- "RGB" , [g , g .transpose (Image .ROTATE_90 ), g .transpose (Image .ROTATE_180 )]
228+ "RGB" ,
229+ [
230+ g ,
231+ g .transpose (Image .Transpose .ROTATE_90 ),
232+ g .transpose (Image .Transpose .ROTATE_180 ),
233+ ],
174234 )
175235
176236 # Red channel copied to alpha
177237 assert_image_equal (
178238 Image .merge ("RGBA" , (im .split () * 2 )[:4 ]),
179239 im ._new (
180240 im .im .color_lut_3d (
181- "RGBA" , Image .LINEAR , * self .generate_identity_table (4 , 17 )
241+ "RGBA" ,
242+ Image .Resampling .BILINEAR ,
243+ * self .generate_identity_table (4 , 17 ),
182244 )
183245 ),
184246 )
@@ -189,32 +251,39 @@ def test_copy_alpha_channel(self):
189251 "RGBA" ,
190252 [
191253 g ,
192- g .transpose (Image .ROTATE_90 ),
193- g .transpose (Image .ROTATE_180 ),
194- g .transpose (Image .ROTATE_270 ),
254+ g .transpose (Image .Transpose . ROTATE_90 ),
255+ g .transpose (Image .Transpose . ROTATE_180 ),
256+ g .transpose (Image .Transpose . ROTATE_270 ),
195257 ],
196258 )
197259
198260 assert_image_equal (
199261 im ,
200262 im ._new (
201263 im .im .color_lut_3d (
202- "RGBA" , Image .LINEAR , * self .generate_identity_table (3 , 17 )
264+ "RGBA" ,
265+ Image .Resampling .BILINEAR ,
266+ * self .generate_identity_table (3 , 17 ),
203267 )
204268 ),
205269 )
206270
207271 def test_channels_order (self ):
208272 g = Image .linear_gradient ("L" )
209273 im = Image .merge (
210- "RGB" , [g , g .transpose (Image .ROTATE_90 ), g .transpose (Image .ROTATE_180 )]
274+ "RGB" ,
275+ [
276+ g ,
277+ g .transpose (Image .Transpose .ROTATE_90 ),
278+ g .transpose (Image .Transpose .ROTATE_180 ),
279+ ],
211280 )
212281
213282 # Reverse channels by splitting and using table
214283 # fmt: off
215284 assert_image_equal (
216285 Image .merge ('RGB' , im .split ()[::- 1 ]),
217- im ._new (im .im .color_lut_3d ('RGB' , Image .LINEAR ,
286+ im ._new (im .im .color_lut_3d ('RGB' , Image .Resampling . BILINEAR ,
218287 3 , 2 , 2 , 2 , [
219288 0 , 0 , 0 , 0 , 0 , 1 ,
220289 0 , 1 , 0 , 0 , 1 , 1 ,
@@ -227,11 +296,16 @@ def test_channels_order(self):
227296 def test_overflow (self ):
228297 g = Image .linear_gradient ("L" )
229298 im = Image .merge (
230- "RGB" , [g , g .transpose (Image .ROTATE_90 ), g .transpose (Image .ROTATE_180 )]
299+ "RGB" ,
300+ [
301+ g ,
302+ g .transpose (Image .Transpose .ROTATE_90 ),
303+ g .transpose (Image .Transpose .ROTATE_180 ),
304+ ],
231305 )
232306
233307 # fmt: off
234- transformed = im ._new (im .im .color_lut_3d ('RGB' , Image .LINEAR ,
308+ transformed = im ._new (im .im .color_lut_3d ('RGB' , Image .Resampling . BILINEAR ,
235309 3 , 2 , 2 , 2 ,
236310 [
237311 - 1 , - 1 , - 1 , 2 , - 1 , - 1 ,
@@ -251,7 +325,7 @@ def test_overflow(self):
251325 assert transformed [205 , 205 ] == (255 , 255 , 0 )
252326
253327 # fmt: off
254- transformed = im ._new (im .im .color_lut_3d ('RGB' , Image .LINEAR ,
328+ transformed = im ._new (im .im .color_lut_3d ('RGB' , Image .Resampling . BILINEAR ,
255329 3 , 2 , 2 , 2 ,
256330 [
257331 - 3 , - 3 , - 3 , 5 , - 3 , - 3 ,
@@ -354,7 +428,12 @@ def test_numpy_sources(self):
354428 def test_numpy_formats (self ):
355429 g = Image .linear_gradient ("L" )
356430 im = Image .merge (
357- "RGB" , [g , g .transpose (Image .ROTATE_90 ), g .transpose (Image .ROTATE_180 )]
431+ "RGB" ,
432+ [
433+ g ,
434+ g .transpose (Image .Transpose .ROTATE_90 ),
435+ g .transpose (Image .Transpose .ROTATE_180 ),
436+ ],
358437 )
359438
360439 lut = ImageFilter .Color3DLUT .generate ((7 , 9 , 11 ), lambda r , g , b : (r , g , b ))
@@ -445,7 +524,12 @@ def test_apply(self):
445524
446525 g = Image .linear_gradient ("L" )
447526 im = Image .merge (
448- "RGB" , [g , g .transpose (Image .ROTATE_90 ), g .transpose (Image .ROTATE_180 )]
527+ "RGB" ,
528+ [
529+ g ,
530+ g .transpose (Image .Transpose .ROTATE_90 ),
531+ g .transpose (Image .Transpose .ROTATE_180 ),
532+ ],
449533 )
450534 assert im == im .filter (lut )
451535
0 commit comments