if 'width' in attrs:
(w, h) = _get_png_geom(path)
if int(w) > image_width:
- attrs['height'] = str(h * image_width / w)
+ attrs['height'] = str(int(round(float(h) * float(image_width) / float(w))))
attrs['width'] = str(image_width)
filename = '''%s-%sx%s%s''' % (root, attrs['width'], attrs['height'], ext)
else: