Skip to content

Instantly share code, notes, and snippets.

@k-okawa
Last active November 13, 2019 09:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k-okawa/e875f00e3adfc2ba0c6e0aa3e2679675 to your computer and use it in GitHub Desktop.
Save k-okawa/e875f00e3adfc2ba0c6e0aa3e2679675 to your computer and use it in GitHub Desktop.
画像を赤くする処理(OpenCV version)
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)
g = int(g * 0.5)
b = int(b * 0.5)
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