Question

I'm cropping an image that was submitted through a form with a jQuery crop plugin. I have the following. But, how can I find out the path to the destination image?

$pic = $this->input->post('pic');

//Get the coordinates from the image crop
$x = $this->input->post('x');
$y = $this->input->post('y');
$w = $this->input->post('w');
$h = $this->input->post('h');

$src = imagecreatefromjpeg($pic);
$dest = ImageCreateTrueColor($w, $h);

imagecopy($dest, $src, $x, $y, $x, $y, $w, $h);
Was it helpful?

Solution

You just need to declare the path.

imagejpeg($dest, '/path/to/save.jpg', 90);

or for smaller images

imagepng($dest, '/path/to/save.jpg', 9);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top