php - Image-cropper causing weird border -


i have gotten stuck trying solve weird issue simple imagecropper webpage. when php processing cropped image , new canvas larger the original image there appears small border around edges of original image inside new canvas.

$x = $_post["left"]; $y = $_post["top"]; $name= pop_extension ($exportname);  if($size == 's'){     $h = 200; //small max height     $w = 200; //small max width     $img_dir = 'small';     $imgname =  $name.'.jpg'; } elseif ($size == 'm'){     $h = 400; //medium max height     $w = 400; //medium max width     $img_dir = 'medium';     $imgname =  $name.'.jpg'; } elseif ($size == 'l'){     $h = 1000; //thumbnail max height     $w = 1000; //thumbnail max width     $img_dir = 'large';     $imgname =  $name.'.jpg'; } $image_size_info    = getimagesize('tmp/'.$exportname); //get image size $image_width = ($_post["width"] != 0)  ? $_post["width"] : $image_size_info[0]; $image_height = ($_post["height"] != 0)  ? $_post["height"] : $image_size_info[1];   if ($image_width > $image_height) {     $width = $w;     $height = round($image_height/$image_width*$w); } else {     $height = $h;     $width = round($image_width/$image_height*$h); } $new_canvas     = imagecreatetruecolor( $width, $height ); $source         = imagecreatefromjpeg('tmp/'.$exportname);  imagecopyresampled($new_canvas, $source, 0, 0, $x, $y, $width, $height, $image_width, $image_height); $white = imagecolorallocate($new_canvas, 255, 255, 255); imagefill($new_canvas, 0, 0, $white); imagejpeg($new_canvas, 'images/products/'.$img_dir.'/'.$imgname, 100); imagedestroy($new_canvas); imagedestroy($source); 

the $x , $y variables position of top left corner of cropper.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -