Last active
July 26, 2019 06:31
-
-
Save k-okawa/357a90c6eeb8f8589a6f8953778f29c5 to your computer and use it in GitHub Desktop.
画像を赤くする処理(Pillow version)
This file contains 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 | |
import sys | |
args = sys.argv | |
argc = len(args) | |
files = args[1:argc] | |
def convert_img(file): | |
img = Image.open(file) | |
size = img.size | |
for x in range(size[0]): | |
for y in range(size[1]): | |
r,g,b,a = img.getpixel((x,y)) | |
r = int((r + 255) / 2) | |
img.putpixel((x,y),(r,g,b,a)) | |
img.save(file,compress_level=9) | |
for file in files: | |
convert_img(file) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment