您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何在PIL / Python中构建图像对象

5b51 2022/1/14 8:23:01 python 字数 819 阅读 557 来源 www.jb51.cc/python

我有一个列表的三项元组列表(PIL. Image.getdata()). 我该怎么做:从这个列表中构建一个PIL.Image对象? getdata()的输出不包括图像格式或大小,因此您需要保留它们(或以其他方式获取信息).然后使用 putdata()方法执行此操作: # get data from old image (as you already did) data = list(oldimg.

概述

我该怎么做:从这个列表中构建一个PIL.Image对象?

# get data from old image (as you already did)
data = list(oldimg.getdata())

# create empty new image of appropriate format
newimg = Image.new(format,size)  # e.g. ('RGB',(640,480))

# insert saved data into the image
newimg.putdata(data)

总结

以上是编程之家为你收集整理的如何在PIL / Python中构建图像对象全部内容,希望文章能够帮你解决如何在PIL / Python中构建图像对象所遇到的程序开发问题。


如果您也喜欢它,动动您的小指点个赞吧

除非注明,文章均由 laddyq.com 整理发布,欢迎转载。

转载请注明:
链接:http://laddyq.com
来源:laddyq.com
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。


联系我
置顶