OSDN Git Service

add wp_imgswap2.py for new OSDN Magazine
[otptools/otptools.git] / sakura_imgswap.py
index a950792..7e4e3e1 100644 (file)
@@ -67,7 +67,7 @@ def replace_img_tag(line, tagstr, path):
     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: