Permalink
Browse files

refs #23: images with 0 height or width no longer throw errors

  • Loading branch information...
1 parent e1458e8 commit 14eea21f9c16629e1c5ad814ea597cbcb877a24d @jlward jlward committed Mar 31, 2013
Showing with 12 additions and 5 deletions.
  1. +12 −5 docx2html/core.py
View
@@ -73,6 +73,9 @@ def get_namespace(el, namespace):
def convert_image(target, image_size):
_, extension = os.path.splitext(os.path.basename(target))
+ # If the image size has a zero in it early return
+ if image_size and not all(image_size):
+ return target
# All the image types need to be converted to gif.
invalid_extensions = (
'.bmp',
@@ -1279,11 +1282,15 @@ def get_p_data(p, meta_data, is_td=False):
else:
target = meta_data.relationship_dict[image_id]
width, height = _get_image_size_from_image(target)
- p_text += '<img src="%s" height="%d" width="%d"/>' % (
- src,
- height,
- width,
- )
+ # Make sure the width and height are not zero
+ if all((width, height)):
+ p_text += '<img src="%s" height="%d" width="%d" />' % (
+ src,
+ height,
+ width,
+ )
+ else:
+ p_text += '<img src="%s" />' % src
# This function does not return a p tag since other tag types need this as
# well (td, li).

0 comments on commit 14eea21

Please sign in to comment.