Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

symfony2 crop image by jcrop datas #77

Closed
lukeman83 opened this issue Feb 7, 2013 · 1 comment
Closed

symfony2 crop image by jcrop datas #77

lukeman83 opened this issue Feb 7, 2013 · 1 comment

Comments

@lukeman83
Copy link

Hi!

I have a crop selection like this:

http://deepliquid.com/projects/Jcrop/demos.php?demo=handler

What must I do to crop my image with X1 Y1 X2 Y2 W H informations?

I'm using Symfony2 framework.

Many Thanks!

@medTheCoder
Copy link

lukeman83,

in your twig, you call an ajax which will call a route assigned to a method controller, waiting for your parameters (that you can transfer by POST method). Then, in your controller, you get these parameters and use them in the given code

getRequest(); if ($_SERVER['REQUEST_METHOD'] == 'POST') { $targ_w = $targ_h = 150; $jpeg_quality = 90; ``` $src = 'demo_files/pool.jpg'; $img_r = imagecreatefromjpeg($src); $dst_r = ImageCreateTrueColor( $targ_w, $targ_h ); imagecopyresampled($dst_r,$img_r,0,0,$_POST['x'],$_POST['y'], $targ_w,$targ_h,$_POST['w'],$_POST['h']); header('Content-type: image/jpeg'); imagejpeg($dst_r,null,$jpeg_quality); exit; ``` } ?>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants