Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- if(isset($_POST['size'])){
- copy($_FILES['logo']['tmp_name'], '002.jpg');
- $s='<img src="002.jpg" /><br/><img src="002Resize.php?x='.$_POST['target']['x'].'&y='.$_POST['target']['y'].'">';
- die($s);
- }
- if(isset($_GET['x'])){
- $img=getimagesize('002.jpg');
- $x1=$img[0]; $y1=$img[1];
- $x2=$_GET['x'];$y2=$_GET['y'];
- $c=array(1, $y2/$x2);
- $x3=$x1;
- $y3=round($x1*$c[1]);
- $x4=round($y1*$c[0] / $c[1]);
- $y4=$y1;
- if($x3<=$x1 && $y3 <= $y1){
- $x0=0;
- $y0=round(($y1-$y3 )/2);
- $wX=$x3; $wY=$y3;
- }
- if($x4<=$x1 && $y4 <= $y1){
- $x0=round(($x1-$x4 )/2);
- $y0=0;
- $wX=$x4; $wY=$y4;
- }
- //die (" 0,0, $x0,$y0, $x2,$y2, $wX,$wY ");
- $im = imagecreatetruecolor($x2, $y2);
- $im0 = imagecreatefromjpeg("002.jpg");
- //$wX=$x2; $wY=$y2;
- //$x0=($x1-$x2) /2 ; $y0=($y1-$y2) / 2;
- header('Content-type: image/jpeg');
- imagecopyresized ( $im, $im0, 0,0, $x0,$y0, $x2,$y2, $wX,$wY);
- imagejpeg($im);
- die();
- }
- ?>
- <form id='gbr' method="post" enctype="multipart/form-data">
- <input name='size' value='1' type='hidden' />
- <!-- size asal X <input name='source[x]' /> Y <input name='source[y]' />-->
- upload : <input type=file name='logo' />
- <br/>
- size tujuan X <input name='target[x]' value='50' /> <br/>Y <input name='target[y]' value='50' /><br/>
- <button id='generate'>Cari</button>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement