范例1:
让我们对尺寸为200×200的图像进行裁剪,然后将其重新缩放为400×400像素。
# Import Image from wand.image module
disappoint的用法、from wand.image import Image
# Import display to display final image
from wand.display import display
# Read image using Image function
python中%的用法。with Image(filename ='koala.jpeg') as img:
# using transform() function
img.transform('200x200', '200 %')
# Saving image
python中len()的用法、img.save(filename ='transform.jpeg')
# display image
display(img)
输出:
python中sorted的用法。范例2:让我们对所有四个角的50%进行图像裁剪。
# Import Image from wand.image module
from wand.image import Image
# Import display to display final image
python中列表的用法、from wand.display import display
# Read image using Image function
with Image(filename ='koala.jpeg') as img:
# using transform() function
python中的from import、img.transform('50 %')
# Saving image
img.save(filename ='transform1.jpeg')
# display image
python中的reversed和reverse、display(img)
输出:
范例3:将源图像的高度缩放到200px,并保留宽高比。
# Import Image from wand.image module
from wand.image import Image
# Import display to display final image
from wand.display import display
# Read image using Image function
with Image(filename ='koala.jpeg') as img:
# using transform() function
img.transform(resize ='x200')
# Saving image
img.save(filename ='transform3.jpeg')
# display image
display(img)
输出:
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态