Created
July 23, 2020 07:55
-
-
Save krossford/3ef98c7af9ecb7882ca42fd40d86ab31 to your computer and use it in GitHub Desktop.
Python Pillow 图像操作
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image | |
img = Image.open("cat.jpg") | |
# 图片尺寸 | |
print(img.size) | |
img.size[0] # 宽度 | |
img.size[1] # 高度 | |
# 操作像素 | |
bitmap = img.load() | |
bitmap[x, y] = (255, 0, 0) | |
# 遍历每个像素点 | |
for x in range(img.size[0]): | |
for y in range(img.size[1]): | |
# do something | |
# 显示 | |
img.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment