Skip to content

Commit

Permalink
fix workflow for enve generated non-tif picture (#75)
Browse files Browse the repository at this point in the history
  • Loading branch information
mariostieriansys authored Oct 26, 2023
1 parent 107a06a commit 1ebebe3
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/ansys/dynamicreporting/core/utils/report_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,8 +266,8 @@ def image_to_data(img):
if has_enve: # pragma: no cover
if isinstance(img, enve.image):
data = dict(width=img.dims[0], height=img.dims[1])
if img.enhanced:
with tempfile.TemporaryDirectory() as temp_dir:
with tempfile.TemporaryDirectory() as temp_dir:
if img.enhanced:
path = os.path.join(temp_dir, "enhanced_image.tif")
# Save the image as a tiff file (enhanced)
if img.save(path, options="Compression Deflate") == 0:
Expand All @@ -279,6 +279,14 @@ def image_to_data(img):
return data
except OSError:
return None
else:
path = os.path.join(temp_dir, "image.png")
if img.save(path) == 0:
try:
with open(path, "rb") as img_file:
return PIL_image_to_data(img_file.read())
except OSError:
return None
if not data:
return PIL_image_to_data(img)

Expand Down

0 comments on commit 1ebebe3

Please sign in to comment.