Updated AffineTransform docstring to mention it uses the inverse matrix by radarhere · Pull Request #8735 · python-pillow/Pillow
The AffineTransform docstring currently states
This function takes a 6-tuple (a, b, c, d, e, f) which contain the first two rows from an affine transform matrix. For each pixel (x, y) in the output image, the new value is taken from a position (a x + b y + c, d x + e y + f) in the input image, rounded to nearest pixel.
#8728 implied that this could be clearer
Yes... I know that PIL takes the inverse
and #8731 is now requesting that we clarify that the inverse matrix is used.
For further reading, see https://stackabuse.com/affine-image-transformations-in-python-with-numpy-pillow-and-opencv/#affinetransformationswithpillow
The
Image.transform(...)method actually requires the inverse of the transformation matrix be supplied to thedataparameter as a flattened array (or tuple) excluding the last row.
So I'm here updating the first sentence to
This function takes a 6-tuple (a, b, c, d, e, f) which contain the first two rows from the inverse of an affine transform matrix.