LoginSignup
0
0

More than 5 years have passed since last update.

PILでtransform

Last updated at Posted at 2018-04-11

概要

PILのtransformを理解したかった。

元画像

p1m.jpg

Image.PERSPECTIVE

a0.png

from PIL import Image

img = Image.open("p1m.jpg")
img = img.transform(img.size, Image.PERSPECTIVE, (3.0, 1.7, -500.0, 0, 3.0, 0, 0.000045, 0.007))
img.save("a0.png");

Image.EXTENT

a1.png

from PIL import Image

img = Image.open("p1m.jpg")
img = img.transform(img.size, Image.EXTENT, (10, 0, 135, 100))
img.save("a1.png");

Image.AFFINE

a2.png

from PIL import Image

img = Image.open("p1m.jpg")
img = img.transform(img.size, Image.AFFINE, (1, 0.1, 0, 0, 1, 0,))
img.save("a2.png");

Image.QUAD

a3.png

from PIL import Image

img = Image.open("p1m.jpg")
img = img.transform(img.size, Image.QUAD, (0, 0, 50, 50, 200, 50, 250, 0))
img.save("a3.png");

Image.MESH

a4.png

from PIL import Image

img = Image.open("p1m.jpg")
(w, h) = img.size
img = img.transform(img.size, Image.MESH, [((0, 0, w // 2, h // 2), (0, 0, 0, h, w, h, w - 100, 0)), ((w // 2, h // 2, w, h), (0, 0, 0, h, w, h, w - 100, 0))])
img.save("a4.png");

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0