PHP crop image from base64_decode
<p>i am generating a screen grab jpg using html2canvas from this code. However i cant target a particaular div so i am grabbing the entire screen.</p>

<pre><code>$canvasImg = $_POST['img'];
$data = base64_decode($canvasImg);
$File = "z.jpg"; 
$Handle = fopen($File, 'w');
fwrite($Handle, $data);  
fclose($Handle);
</code></pre>

<p><br/>
<strong>question</strong>: how can i crop the image?<br/><br/>
this is my attampt</p>

<pre><code>$canvasImg = $_POST['img'];
$image = base64_decode($canvasImg);
$dest_image = 'z.jpg';
$img = imagecreatetruecolor('200','150');
$org_img = imagecreatefromstring($image);
$ims = getimagesize($image);
imagecopy($img,$org_img, 0, 0, 20, 20, 200, 150);
imagejpeg($img,$dest_image,90);
imagedestroy($img);
</code></pre>

<p><br/><br/>
but im getting a errors<br/>
<code>Warning: getimagesize(�PNG  ) [&lt;a href='function.getimagesize'&gt;function.getimagesize&lt;/a&gt;]: failed to open stream: Invalid argument</code></p>
