Python模块_PyLibTiff读取tif文件的实例
2020-06-25 08:07:41 来源:易采站长站 作者:易采站长站整理
>>>out = im.transpose(Image.FLIP_TOP_BOTTOM) #上下对换。
>>>out = im.transpose(Image.ROTATE_90) #旋转 90 度角。
>>>out = im.transpose(Image.ROTATE_180) #旋转 180 度角。
>>>out = im.transpose(Image.ROTATE_270) #旋转 270 度角。
Image 类的 thumbnail() 方法可以用来制作缩略图。它接受一个二元数组作为缩略图的尺寸,然后将示例缩小到指定尺寸。
import os, sys
from PIL import Imagefor infile in sys.argv[1:]:
outfile = os.path.splitext(infile)[0] + ".thumbnail"
if infile != outfile:
try:
im = Image.open(infile)
x, y = im.size
im.thumbnail((x//2, y//2))
im.save(outfile, "JPEG")
except IOError:
print "cannot create thumbnail for", infile
这里我们用 im.size 获取原图档的尺寸,然后以 thumbnail() 制作缩略图,大小则是原先图档的四分之一。同样,如果图档无法打开,则在终端上打印无法执行的提示。
PIL.Image.fromarray(obj, mode=None)
Creates an image memory from an object exporting the array interface (using the buffer protocol).If obj is not contiguous, then the tobytes method is called and frombuffer() is used.
Parameters:
obj – Object with array interface
mode – Mode to use (will be determined from type if None) See: Modes.
Returns:
An image object.
New in version 1.1.6.
PIL文档
以上这篇Python模块_PyLibTiff读取tif文件的实例就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持软件开发网。
您可能感兴趣的文章:python3读取csv文件任意行列代码实例Python如何读取文件中图片格式Python读取YAML文件过程详解Python读取csv文件实例解析Python3 解决读取中文文件txt编码的问题Python3.7 读取 mp3 音频文件生成波形图效果Python从文件中读取指定的行以及在文件指定位置写入使用Python脚本从文件读取数据代码实例













闽公网安备 35020302000061号