Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated AffineTransform docstring to mention it uses the inverse matrix #8735

Merged
merged 1 commit into from
Feb 6, 2025

Conversation

radarhere
Copy link
Member

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 the data parameter 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.

@hugovk hugovk merged commit b57b4e5 into python-pillow:main Feb 6, 2025
51 of 52 checks passed
@radarhere radarhere deleted the affine branch February 6, 2025 11:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants