Pregunta

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);
¿Fue útil?

Solución

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);
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top