PauloRJ 4 Denunciar post Postado Abril 7, 2009 Como pegar a imagem gerada pelo crop e enviar para um diretorio. Quero salvar essa nova imagem e gravar o nome dela no banco de dados. Consigo gerar a thumb mas nao trabalhar dai em diante. Segue o codigo que estou usando: Fonte: http://deepliquid.com/projects/Jcrop/demos...?demo=live_crop crop.php <?php /** * Jcrop image cropping plugin for jQuery * Example cropping script * @copyright 2008 Kelly Hallman * More info: http://deepliquid.com/content/Jcrop_Implementation_Theory.html */ if ($_SERVER['REQUEST_METHOD'] == 'POST') { $targ_w = $targ_h = 100; $jpeg_quality = 90; $src = 'demo_files/flowers.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; } // If not a POST request, display page below: ?><html> <head> <script src="../js/jquery.pack.js"></script> <script src="../js/jquery.Jcrop.pack.js"></script> <link rel="stylesheet" href="../css/jquery.Jcrop.css" type="text/css" /> <link rel="stylesheet" href="demo_files/demos.css" type="text/css" /> <script language="Javascript"> $(function(){ $('#cropbox').Jcrop({ aspectRatio: 1, onSelect: updateCoords }); }); function updateCoords(c) { $('#x').val(c.x); $('#y').val(c.y); $('#w').val(c.w); $('#h').val(c.h); }; function checkCoords() { if (parseInt($('#w').val())) return true; alert('Please select a crop region then press submit.'); return false; }; </script> </head> <body> <div id="outer"> <div class="jcExample"> <div class="article"> <h1>Jcrop - Crop Behavior</h1> <!-- This is the image we're attaching Jcrop to --> <img src="demo_files/flowers.jpg" id="cropbox" /> <!-- This is the form that our event handler fills --> <form action="crop.php" method="post" onSubmit="return checkCoords();"> <input type="hidden" id="x" name="x" /> <input type="hidden" id="y" name="y" /> <input type="hidden" id="w" name="w" /> <input type="hidden" id="h" name="h" /> <input type="submit" value="Crop Image" /> </form> <p> <b>An example server-side crop script.</b> Hidden form values are set when a selection is made. If you press the <i>Crop Image</i> button, the form will be submitted and a 150x150 thumbnail will be dumped to the browser. Try it! </p> <div id="dl_links"> <a href="http://deepliquid.com/content/Jcrop.html">Jcrop Home</a> | <a href="http://deepliquid.com/content/Jcrop_Manual.html">Manual (Docs)</a> </div> </div> </div> </div> </body> </html> Compartilhar este post Link para o post Compartilhar em outros sites
Marcio Leandro 0 Denunciar post Postado Abril 8, 2009 O formulário vai enviar as variáveis que indicam os pontos da imagem que representa a área selecionada: <input type="hidden" id="x" name="x" /> <input type="hidden" id="y" name="y" /> <input type="hidden" id="w" name="w" /> <input type="hidden" id="h" name="h" />Use esses valores para cortar a imagem, eles são os mesmos utilizados pelas funções da GD. Compartilhar este post Link para o post Compartilhar em outros sites
PauloRJ 4 Denunciar post Postado Abril 8, 2009 Certo, mas gera a imagem eu consigo o problema e pegar essa nova imagem gerada e enviar direto para o diretorio entende? Na verdade eu nao preciso nem exibir ela dps recortada. Porque ele exibe a imagem recortada perceitamente quando dou o submit no form, mas e trabalhar com ela dps? Queria algo dinamico, seleciono, corto mando pro diretorio ae eu atualizo no bd o nome e fica tudo show! entendes?! essa e a questao como enviar direto pro diretorio a nova imagem Compartilhar este post Link para o post Compartilhar em outros sites
Marcio Leandro 0 Denunciar post Postado Abril 15, 2009 Dê uma olhada nos parâmetros da função imagejpeg, por exemplo: http://br.php.net/manual/pt_BR/function.imagejpeg.php Compartilhar este post Link para o post Compartilhar em outros sites
PauloRJ 4 Denunciar post Postado Abril 15, 2009 Teria algum exemplo pratico disso? Compartilhar este post Link para o post Compartilhar em outros sites
Marcio Leandro 0 Denunciar post Postado Abril 15, 2009 Tirado do manual: bool imagejpeg ( resource $image [, string $filename [, int $quality ]] ) O segundo parametro, caso seja informado, salva a imagem na caminho informado. Compartilhar este post Link para o post Compartilhar em outros sites
SHWE12 1 Denunciar post Postado Setembro 30, 2010 rapaz também to precisando disso e nao consigo salvar a imagem nova esse é o script que recebe a imagem cortada.. a partir dele tem q salvar a imagem nova, mas isso q nao estou conseguindo. if ($_SERVER['REQUEST_METHOD'] == 'POST') { $targ_w = $targ_h = 200; $jpeg_quality = 90; $src = 'sis/imagens/fotos/'.$_SESSION['foto'].''; $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; } // If not a POST request, display page below: nada ainda.... putz.. ele nao salva.. Compartilhar este post Link para o post Compartilhar em outros sites