title: How to shear image around a center in PIL?
body: <p>I was thinking, that I could shear an image around center by first translating it, then shearing, then translating back.</p>
  
  <pre><code>def translate(im: Image.Image, tx: float=0, ty: float=0):
      return im.transform(im.size, Image.AFFINE, (1, 0, tx, 0, 1, ty))
  
  def shear(im: Image.Image, cx=0, cy=0):
      center = [xy/2 for xy in im.size]
      im = translate(im, center[0], center[1])
      im = im.transform(im.size, Image.AFFINE, (1, cx, 0, cy, 1, 0))
      im = translate(im, -center[0], -center[1])
      return im
  </code></pre>
  
  <p>Unfortunately, translation looses information and I get the following</p>
  
  <p><a href="https://i.stack.imgur.com/CwUQJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CwUQJ.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/LPxCP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LPxCP.png" alt="enter image description here"></a></p>