Skip to content

Instantly share code, notes, and snippets.

@hamaguchi-amago
Created February 14, 2023 22:35
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 hamaguchi-amago/5aba8ff893ba3bab290ac88125f7aa52 to your computer and use it in GitHub Desktop.
Save hamaguchi-amago/5aba8ff893ba3bab290ac88125f7aa52 to your computer and use it in GitHub Desktop.
from PIL import Image
# Macだとプレビューで開く
im = Image.open("cat.jpg")
print(im.mode)
print(im.size)
print(im.width)
print(im.height)
im.show()
# 回転させる
im45 = im.rotate(45)
im45.show()
# (90, 60) のサムネイル
im.thumbnail((90, 60))
im.save("cat-thumb.jpg")
# JPG -> PNG
im = Image.open("cat.jpg")
im.save("cat.png")
@hamaguchi-amago
Copy link
Author

ブログのサンプルとして作成しました。

【Python】Pillowライブラリを使って簡単な画像処理を試す
https://neko-py.com/python-image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment