9
9
del sys .path [0 ]
10
10
11
11
from PIL import Image , ImageDraw , ImageFilter , ImageMath
12
+ from PIL import features
12
13
13
14
if "--installed" in sys .argv :
14
15
sys .path .insert (0 , sys_path_0 )
@@ -162,22 +163,6 @@ def testimage():
162
163
"""
163
164
164
165
165
- def check_module (feature , module ):
166
- try :
167
- __import__ (module )
168
- except ImportError :
169
- print ("***" , feature , "support not installed" )
170
- else :
171
- print ("---" , feature , "support ok" )
172
-
173
-
174
- def check_codec (feature , codec ):
175
- if codec + "_encoder" not in dir (Image .core ):
176
- print ("***" , feature , "support not installed" )
177
- else :
178
- print ("---" , feature , "support ok" )
179
-
180
-
181
166
if __name__ == "__main__" :
182
167
# check build sanity
183
168
@@ -189,23 +174,22 @@ def check_codec(feature, codec):
189
174
print ("Python modules loaded from" , os .path .dirname (Image .__file__ ))
190
175
print ("Binary modules loaded from" , os .path .dirname (Image .core .__file__ ))
191
176
print ("-" * 68 )
192
- check_module ("PIL CORE" , "PIL._imaging" )
193
- check_module ("TKINTER" , "PIL._imagingtk" )
194
- check_codec ("JPEG" , "jpeg" )
195
- check_codec ("JPEG 2000" , "jpeg2k" )
196
- check_codec ("ZLIB (PNG/ZIP)" , "zip" )
197
- check_codec ("LIBTIFF" , "libtiff" )
198
- check_module ("FREETYPE2" , "PIL._imagingft" )
199
- check_module ("LITTLECMS2" , "PIL._imagingcms" )
200
- check_module ("WEBP" , "PIL._webp" )
201
- try :
202
- from PIL import _webp
203
- if _webp .WebPDecoderBuggyAlpha ():
204
- print ("***" , "Transparent WEBP" , "support not installed" )
177
+ for feature in features .get_all_modules ():
178
+ supported = features .check_module (feature )
179
+
180
+ if supported is None :
181
+ # A method was being tested, but the module required
182
+ # for the method could not be correctly imported
183
+ pass
184
+ elif supported :
185
+ print ("---" , feature , "support ok" )
186
+ else :
187
+ print ("***" , feature , "support not installed" )
188
+ for feature in features .get_all_codecs ():
189
+ if features .check_codec (feature ):
190
+ print ("---" , feature , "support ok" )
205
191
else :
206
- print ("---" , "Transparent WEBP" , "support ok" )
207
- except Exception :
208
- pass
192
+ print ("***" , feature , "support not installed" )
209
193
print ("-" * 68 )
210
194
211
195
# use doctest to make sure the test program behaves as documented!
0 commit comments