sightmachine / SimpleCV

The Open Source Framework for Machine Vision
http://simplecv.org
BSD 3-Clause "New" or "Revised" License
2.68k stars 798 forks source link

Resize image by fractions throws exception #624

Open Svenito opened 10 years ago

Svenito commented 10 years ago

If you try to resize an image with a fraction (0.5) a TypeError exception is thrown. This is because the call to cv.CreateImage expects int not float types. I would suggest casting w and h to int.

scaled_bitmap = cv.CreateImage((int(w), int(h)), 8, 3)

example:

img = Image("img.jpg")
img.resize(img.width * 0.5, img.height * 0.5)

Not sure if this is acceptable, but it would make more sense than casting the arguments to the resize call to int. I have a pull request lined up, but due to my vim's whitespace cleanup it's going to push a lot of whitespace changes, so I need to redo the commit if this change is acceptable.