File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
src/ansys/dynamicreporting/core/utils Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -266,8 +266,8 @@ def image_to_data(img):
266266 if has_enve : # pragma: no cover
267267 if isinstance (img , enve .image ):
268268 data = dict (width = img .dims [0 ], height = img .dims [1 ])
269- if img . enhanced :
270- with tempfile . TemporaryDirectory () as temp_dir :
269+ with tempfile . TemporaryDirectory () as temp_dir :
270+ if img . enhanced :
271271 path = os .path .join (temp_dir , "enhanced_image.tif" )
272272 # Save the image as a tiff file (enhanced)
273273 if img .save (path , options = "Compression Deflate" ) == 0 :
@@ -279,6 +279,14 @@ def image_to_data(img):
279279 return data
280280 except OSError :
281281 return None
282+ else :
283+ path = os .path .join (temp_dir , "image.png" )
284+ if img .save (path ) == 0 :
285+ try :
286+ with open (path , "rb" ) as img_file :
287+ return PIL_image_to_data (img_file .read ())
288+ except OSError :
289+ return None
282290 if not data :
283291 return PIL_image_to_data (img )
284292
You can’t perform that action at this time.
0 commit comments