How to set coordinates when cropping an image with PIL?
<p>I don't know how to set the coordinates to crop an image in <code>PIL</code>s <code>crop()</code>:</p>

<pre><code>from PIL import Image
img = Image.open("Supernatural.xlsxscreenshot.png")
img2 = img.crop((0, 0, 201, 335))
img2.save("img2.jpg")
</code></pre>

<p>I tried with <code>gThumb</code> to get coordinates, but if I take an area which I would like to crop, I can only find position 194 336. Could someone help me please?</p>

<p>This is my picture:</p>

<p><a href="http://i.stack.imgur.com/1twQc.png" rel="nofollow"><img src="http://i.stack.imgur.com/1twQc.png" alt="enter image description here"></a></p>

<p>I wish to crop to this:</p>

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

<h3>How to set the coordinates to crop</h3>

<p>In the line:</p>

<pre><code>img2 = img.crop((0, 0, 201, 335))
</code></pre>

<p>the first two numbers define the <em>top-left</em> coordinates of the outtake (x,y), while the last two define the <em>right-bottom</em> coordinates of the outtake.</p>

<h3>Cropping your image</h3>

<p>To crop your image like you show, I found the following coordinates: top-left: <code>(200, 330)</code>, and right-bottom: <code>(730, 606)</code>. Subsequently, I cropped your image with:</p>

<pre><code>img2 = img.crop((200, 330, 730, 606))
</code></pre>

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

<p>with the result:</p>

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

python image python-2.7 python-3.x image-processing