Skip to content

Commit 1ebebe3

Browse files
fix workflow for enve generated non-tif picture (#75)
1 parent 107a06a commit 1ebebe3

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/ansys/dynamicreporting/core/utils/report_utils.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)