File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -138,8 +138,17 @@ def simulated_setup_from_image(
138138 conf={'filepath': path_to_image_file}),
139139 ]
140140 """
141- PIL .Image .MAX_IMAGE_PIXELS = None
142- image = np .array (PIL .Image .open (filepath ))
141+ # PIL will error if trying to open very large images to avoid
142+ # decompression bomb DOS attack. However, this is used to fake a
143+ # stage and will really have very very large images, so remove
144+ # remove the PIL limit temporarily.
145+ original_pil_max_image_pixels = PIL .Image .MAX_IMAGE_PIXELS
146+ try :
147+ PIL .Image .MAX_IMAGE_PIXELS = None
148+ image = np .array (PIL .Image .open (filepath ))
149+ finally :
150+ PIL .Image .MAX_IMAGE_PIXELS = original_pil_max_image_pixels
151+
143152 if len (image .shape ) < 3 :
144153 raise ValueError ("not an RGB image" )
145154
You can’t perform that action at this time.
0 commit comments