简体   繁体   English

如何在Python中按比例放大图片?

[英]How to scale up picture in Python?

I am really do not know how to scale up a part of picture. 我真的不知道如何放大图片的一部分。 I need scale up someone's nose. 我需要扩大别人的鼻子。

Example: 例:

def scaleUp():
    pic=makePicture(pickAFile())
    width=getWidth()
    height=getHeight()

You can use Pillow library to do that: 您可以使用枕头库来做到这一点:

import Image

infile = "test.png"
outfile = "test_resized.jpg"
size = (1024, 768)

im = Image.open(infile)
print im.size   # Size in pixels

# Resize:
im.resize(size, Image.ANTIALIAS)
im.save(outfile, "JPEG")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM