diff --git a/src/wireviz/DataClasses.py b/src/wireviz/DataClasses.py
index 622912a..bde12f5 100644
--- a/src/wireviz/DataClasses.py
+++ b/src/wireviz/DataClasses.py
@@ -16,24 +16,26 @@ class Image:
width: Optional[int] = None
height: Optional[int] = None
fixedsize: Optional[bool] = None
- # Contents of the cell
just below the image cell:
+ # Contents of the text cell | just below the image cell:
caption: Optional[str] = None
# See also HTML doc at https://graphviz.org/doc/info/shapes.html#html
def __post_init__(self):
if self.scale is None:
- self.scale = "false" if self.width is None and self.height is None \
- else "both" if self.width is not None and self.height is not None \
+ self.scale = "false" if not self.width and not self.height \
+ else "both" if self.width and self.height \
else "true" # When only one dimension is specified.
if self.fixedsize is None:
- self.fixedsize = self.width is not None or self.height is not None
+ self.fixedsize = self.width or self.height
- if self.width is None and self.height is not None:
- self.width = self.height # Assuming 1:1 aspect ratio for now.
- elif self.height is None and self.width is not None:
- self.height = self.width # Assuming 1:1 aspect ratio for now.
+ if self.height:
+ if not self.width:
+ self.width = self.height # Assuming 1:1 aspect ratio for now.
+ else:
+ if self.width:
+ self.height = self.width # Assuming 1:1 aspect ratio for now.
@dataclass
diff --git a/src/wireviz/wv_helper.py b/src/wireviz/wv_helper.py
index 0bc8139..33936ed 100644
--- a/src/wireviz/wv_helper.py
+++ b/src/wireviz/wv_helper.py
@@ -75,8 +75,8 @@ def html_caption(image):
def html_size_attr(image):
# Return Graphviz HTML attributes to specify minimum or fixed size of a TABLE or TD object
- return ((f' width="{image.width}"' if image.width is not None else '')
- + (f' height="{image.height}"' if image.height is not None else '')
+ return ((f' width="{image.width}"' if image.width else '')
+ + (f' height="{image.height}"' if image.height else '')
+ ( ' fixedsize="true"' if image.fixedsize else '')) if image else ''
|