public function process($saveToFilePath = null, $retainFileExt = false)
{
//$saveToFilePath = 'http://'.$_SERVER['SERVER_NAME'].'/admin/crop/picture/';
// list($width, $height) = getimagesize($_POST["imageSource"]);
// $viewPortW = $_POST["viewPortW"];
//$viewPortH = $_POST["viewPortH"];
$pWidth = $_POST["imageW"];
$pHeight = $_POST["imageH"];
$ext = end(explode(".", $_POST["imageSource"]));
$function = $this->returnCorrectFunction($ext);
$image = $function($_POST["imageSource"]);
$width = imagesx($image);
$height = imagesy($image);
// Resample
$image_p = imagecreatetruecolor($pWidth, $pHeight);
$this->setTransparency($image, $image_p, $ext);
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $pWidth, $pHeight, $width, $height);
imagedestroy($image);
$widthR = imagesx($image_p);
$hegihtR = imagesy($image_p);
$selectorX = $_POST["selectorX"];
$selectorY = $_POST["selectorY"];
if ($_POST["imageRotate"]) {
$angle = 360 - $_POST["imageRotate"];
$image_p = imagerotate($image_p, $angle, 0);
$pWidth = imagesx($image_p);
$pHeight = imagesy($image_p);
//print $pWidth."---".$pHeight;
$diffW = abs($pWidth - $widthR) / 2;
$diffH = abs($pHeight - $hegihtR) / 2;
$_POST["imageX"] = ($pWidth > $widthR ? $_POST["imageX"] - $diffW : $_POST["imageX"] + $diffW);
$_POST["imageY"] = ($pHeight > $hegihtR ? $_POST["imageY"] - $diffH : $_POST["imageY"] + $diffH);
}
$dst_x = $src_x = $dst_y = $src_y = 0;
if ($_POST["imageX"] > 0) {
$dst_x = abs($_POST["imageX"]);
} else {
$src_x = abs($_POST["imageX"]);
}
if ($_POST["imageY"] > 0) {
$dst_y = abs($_POST["imageY"]);
} else {
$src_y = abs($_POST["imageY"]);
}
$viewport = imagecreatetruecolor($_POST["viewPortW"], $_POST["viewPortH"]);
$this->setTransparency($image_p, $viewport, $ext);
imagecopy($viewport, $image_p, $dst_x, $dst_y, $src_x, $src_y, $pWidth, $pHeight);
imagedestroy($image_p);
$selector = imagecreatetruecolor($_POST["selectorW"], $_POST["selectorH"]);
$this->setTransparency($viewport, $selector, $ext);
$a = imagecopy($selector, $viewport, 0, 0, $selectorX, $selectorY, $_POST["viewPortW"], $_POST["viewPortH"]);
$saveToFilePath = ($retainFileExt == true) ? $saveToFilePath . '.' . $ext : $saveToFilePath;
$this->parseImage($ext, $selector, $saveToFilePath);
imagedestroy($viewport);
//Return value
return $this;
/* Functions */
}
does this run a function?Good grief, how would I know? Where did you get this code? It doesn't really make sense to me (looks like it is a fragment that was ripped out of a larger class) but I figured if you were using it, you understood it and trusted it.
public function process($saveToFilePath = null, $retainFileExt = false)
{
setcookie("cropzoomehandler", "1");
//$saveToFilePath = 'http://'.$_SERVER['SERVER_NAME'].'/admin/crop/picture/';
// list($width, $height) = getimagesize($_POST["imageSource"]);
// $viewPortW = $_POST["viewPortW"];
//$viewPortH = $_POST["viewPortH"];
$pWidth = $_POST["imageW"];
$pHeight = $_POST["imageH"];
$ext = end(explode(".", $_POST["imageSource"]));
setcookie("cropzoomehandler", "2");
$function = $this->returnCorrectFunction($ext);
setcookie("cropzoomehandler", "3");
$image = $function($_POST["imageSource"]);
setcookie("test", 'test' );
$width = imagesx($image);
$height = imagesy($image);
setcookie("cropzoomehandler", "4");
// Resample
$image_p = imagecreatetruecolor($pWidth, $pHeight);
$this->setTransparency($image, $image_p, $ext);
setcookie("cropzoomehandler", "5");
imagecopyresampled($image_p, $image, 0, 0, 0, 0, $pWidth, $pHeight, $width, $height);
setcookie("cropzoomehandler", "6");
imagedestroy($image);
$widthR = imagesx($image_p);
$hegihtR = imagesy($image_p);
setcookie("cropzoomehandler", "7");
$selectorX = $_POST["selectorX"];
$selectorY = $_POST["selectorY"];
if ($_POST["imageRotate"]) {
$angle = 360 - $_POST["imageRotate"];
$image_p = imagerotate($image_p, $angle, 0);
$pWidth = imagesx($image_p);
$pHeight = imagesy($image_p);
//print $pWidth."---".$pHeight;
$diffW = abs($pWidth - $widthR) / 2;
$diffH = abs($pHeight - $hegihtR) / 2;
$_POST["imageX"] = ($pWidth > $widthR ? $_POST["imageX"] - $diffW : $_POST["imageX"] + $diffW);
$_POST["imageY"] = ($pHeight > $hegihtR ? $_POST["imageY"] - $diffH : $_POST["imageY"] + $diffH);
}
$dst_x = $src_x = $dst_y = $src_y = 0;
setcookie("cropzoomehandler", "8");
if ($_POST["imageX"] > 0) {
$dst_x = abs($_POST["imageX"]);
} else {
$src_x = abs($_POST["imageX"]);
}
if ($_POST["imageY"] > 0) {
$dst_y = abs($_POST["imageY"]);
} else {
$src_y = abs($_POST["imageY"]);
}
setcookie("cropzoomehandler", "9");
$viewport = imagecreatetruecolor($_POST["viewPortW"], $_POST["viewPortH"]);
$this->setTransparency($image_p, $viewport, $ext);
imagecopy($viewport, $image_p, $dst_x, $dst_y, $src_x, $src_y, $pWidth, $pHeight);
imagedestroy($image_p);
$selector = imagecreatetruecolor($_POST["selectorW"], $_POST["selectorH"]);
$this->setTransparency($viewport, $selector, $ext);
$a = imagecopy($selector, $viewport, 0, 0, $selectorX, $selectorY, $_POST["viewPortW"], $_POST["viewPortH"]);
$saveToFilePath = ($retainFileExt == true) ? $saveToFilePath . '.' . $ext : $saveToFilePath;
setcookie("cropzoomehandler", "10");
$this->parseImage($ext, $selector, $saveToFilePath);
imagedestroy($viewport);
//Return value
return $this;
/* Functions */
}
Open in new window