Good day.
i have problem with a crop image.
original image:
after use code i give next image:
Code for crop image:
$pathTemp = '../Images/Temp/';
$path = '../Images/';
$pathCrop = '../Images/Crop/';
if($image=='0'){die('error_image');}
if (!copy($pathTemp.$image, $path.$image)){die('error_image');}
$ext_arr = explode('.',$image);
$ext = $ext_arr[1];
$jpeg_quality = 90;
$src = $pathCrop.$image;
$img_r = imagecreatefromjpeg($src);
$dst_r = imagecreatetruecolor($_POST['w'], $_POST['h']);
imagecopyresized($dst_r,$img_r,0,0,$_POST['x1'],$_POST['y1'],170,110,$_POST['w'],$_POST['h']);
imagejpeg($dst_r,$pathCrop.time().'.jpg',$jpeg_quality);
Tell me please where i have error?
Why i get bad end image?
Your script works, I think that your problem is the location of the original image.
Isn't your original image supposed to be in the $path
folder ? You're looking for it in the $pathCrop
folder.
$src = $pathCrop.$image;
Then $img_r
is empty, so when you copy it to $dst_r
you have a black image.
Try replacing
$src = $pathCrop.$image;
by
$src = $path.$image;