2
# The Python Imaging Library.
8
# 2002-04-08 fl Created
10
# Copyright (c) 2002 by Secret Labs AB
11
# Copyright (c) 2002 by Fredrik Lundh
13
# See the README file for information on usage and redistribution.
18
class Transform(Image.ImageTransformHandler):
19
def __init__(self, data):
22
return self.method, self.data
23
def transform(self, size, image, **options):
25
method, data = self.getdata()
26
return image.transform(size, method, data, **options)
29
# Define an affine image transform.
31
# This function takes a 6-tuple (<i>a, b, c, d, e, f</i>) which
32
# contain the first two rows from an affine transform matrix. For
33
# each pixel (<i>x, y</i>) in the output image, the new value is
34
# taken from a position (a <i>x</i> + b <i>y</i> + c,
35
# d <i>x</i> + e <i>y</i> + f) in the input image, rounded to
38
# This function can be used to scale, translate, rotate, and shear the
41
# @def AffineTransform(matrix)
42
# @param matrix A 6-tuple (<i>a, b, c, d, e, f</i>) containing
43
# the first two rows from an affine transform matrix.
44
# @see Image#Image.transform
46
class AffineTransform(Transform):
50
# Define a transform to extract a subregion from an image.
52
# Maps a rectangle (defined by two corners) from the image to a
53
# rectangle of the given size. The resulting image will contain
54
# data sampled from between the corners, such that (<i>x0, y0</i>)
55
# in the input image will end up at (0,0) in the output image,
56
# and (<i>x1, y1</i>) at <i>size</i>.
58
# This method can be used to crop, stretch, shrink, or mirror an
59
# arbitrary rectangle in the current image. It is slightly slower than
60
# <b>crop</b>, but about as fast as a corresponding <b>resize</b>
63
# @def ExtentTransform(bbox)
64
# @param bbox A 4-tuple (<i>x0, y0, x1, y1</i>) which specifies
65
# two points in the input image's coordinate system.
66
# @see Image#Image.transform
68
class ExtentTransform(Transform):
72
# Define an quad image transform.
74
# Maps a quadrilateral (a region defined by four corners) from the
75
# image to a rectangle of the given size.
77
# @def QuadTransform(xy)
78
# @param xy An 8-tuple (<i>x0, y0, x1, y1, x2, y2, y3, y3</i>) which
79
# contain the upper left, lower left, lower right, and upper right
80
# corner of the source quadrilateral.
81
# @see Image#Image.transform
83
class QuadTransform(Transform):
87
# Define an mesh image transform. A mesh transform consists of one
88
# or more individual quad transforms.
90
# @def MeshTransform(data)
91
# @param data A list of (bbox, quad) tuples.
92
# @see Image#Image.transform
94
class MeshTransform(Transform):