Cutting image background is black (PHP,PNG)

Wednesday, November 4, 2015

Cutting image background is black.



My code :



$filename = "../upload/".$name;
$new_filename = "../upload/".$name;
list($current_width, $current_height) = getimagesize($filename);
$x1 = clear($_POST["x1"]);
$y1 = clear($_POST["y1"]);
$x2 = clear($_POST["x2"]);
$y2 = clear($_POST["y2"]);
$w = clear($_POST["width"]);
$h = clear($_POST["height"]);
$crop_width = clear($_POST["width"]);
$crop_height = clear($_POST["height"]);
$new = imagecreatetruecolor($crop_width, $crop_height);
$current_image = imagecreatefrompng($filename);

$red = imagecolorallocate($current_image, 255, 0, 0);
$black = imagecolorallocate($current_image, 0, 0, 0);

imagecopyresampled($new, $current_image, 0, 0, $x1, $y1, $crop_width, $crop_height, $w, $h);
header('Content-Type: image/png');
imagepng($new, $new_filename);
imagedestroy($current_image);

0 comments:

Post a Comment