Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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