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.
$canvasImg = $_POST['img'];
$data = base64_decode($canvasImg);
$File = "z.jpg";
$Handle = fopen($File, 'w');
fwrite($Handle, $data);
fclose($Handle);
question: how can i crop the image?
this is my attampt
$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);
but im getting a errors
Warning: getimagesize(�PNG ) [<a href='function.getimagesize'>function.getimagesize</a>]: failed to open stream: Invalid argument
the first param of
getimagesize($image);must be the image’s filename.