only rotate part of image python
<p>Can someone tell me how to rotate only part of an image like this:</p>

<p><a href="http://i.stack.imgur.com/8MEVW.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/8MEVW.jpg" alt="this"></a></p>

<p>How to find coordinate / center of this image:</p>

<p><a href="http://i.stack.imgur.com/PxGtN.png" rel="nofollow"><img src="http://i.stack.imgur.com/PxGtN.png" alt="image"></a></p>

<p>i can rotate all pict using this</p>

<pre><code>from PIL import Image

def rotate_image():
img = Image.open("nime1.png")

img.rotate(45).save("plus45.png")
img.rotate(-45).save("minus45.png")

img.rotate(90).save("90.png")
img.transpose(Image.ROTATE_90).save("90_trans.png")

img.rotate(180).save("180.png")


if __name__ == '__main__':
rotate_image()
</code></pre>

<p>You can solve this problem as such. Say you have <code>img = Image.open("nime1.png")</code></p>

<ol>
<li>Create a copy of the image using img2 = img.copy()</li>
<li>Create a crop of img2 at the desired location using img2.crop(). You can read how to do this <a href="http://stackoverflow.com/questions/890051/how-do-i-generate-circular-thumbnails-with-pil">here</a></li>
<li>Paste img2 back onto img at the appropriate location using img.paste()</li>
</ol>

<h1>Notes:</h1>

<p>To find the center coordinate, you can divide the width and height by 2 :)</p>

python image rotation python-imaging-library python-3.4