0

I was working on getting a few images to skew and I found this source which had some code for skewing an Image along the x-axis:

width, height = self.get_size()  # This is defined elsewhere to get the height & width of the image
new_width = width + int(round(abs(scale) * width))
self.img_PIL = self.img_PIL.transform((new_width, height), Img.AFFINE,
                                      (1, scale, -(abs(scale) * width) if scale > 0 else 0, 0, 1, 0)

But I don't seem to understand what this means... what are the 4 tuple values 0, 0, 1, 0? What is (1, scale, -(abs(scale) * width). And lastly, how would I adapt this for skewing the image on the y-axis? I would prefer to understand the logic behind the tuples because I would be able to adapt this for the y-axis myself.

Bhavye Mathur
  • 1,024
  • 1
  • 7
  • 25
  • 1
    The tuple is the `data` parameter to be used with the transformation method. This answer provides a lot of detail: https://stackoverflow.com/a/17141975/10987432 – Paul M. Jul 15 '20 at 09:00
  • I see, thanks! it took a bit of work, but I think I'm almost properly skewing the image. – Bhavye Mathur Jul 15 '20 at 10:26

0 Answers0