开发者

A neat and clean algorithm for the image resize

I need a better and clean algorithm for resizing and Image. My Images are mostly large and I want to resize it smaller size without much degradation of quality. I am using pytho开发者_如何学Cn image library PIL. Here I found An algorithm for resizing . when My Original image width is greater than the length then it seems to works fine but when length of original image is greater than the width of original image it (the algorithm) seems to be broken.

Please suggest me any better algo. Thanks


I've used this before and it works for image with length > width and for any common image format.

img = Image.open(filename)
img.thumbnail((100,100))

Even in the case that the algo is broken for length > width but works when length < width. You can rotate the image by 90 degree first, resize it and rotate it back.

img=img.rotate(90)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜