SilentQ-noob- Posted July 11, 2007 Share Posted July 11, 2007 Hi, I want to make a piece of code where I have a form with the fields width and height. The forced dimensions of the image are W: 120 and H: 90. I want to make two boxes with the names width and height, and when somebody enters nwe numbers into the fields and clicks resize, the image resizes accordingly. I've got the HTML form: <img id="pic" src="images/click.jpg" width="120" height="90"> <br/> <form action="form.php" method="post"> <caption>Enter new numbers to resize the image</caption><br/> Width: <input name ="width" type="text" value="120"> <br/> Height: <input name ="height" type="text" value="90"> <br /> <input type="submit" value="RESIZE"> </form> I think what I have to do is create variables $height and $width, and then update them with values from $_POST['height'] and $_POST['width'] - I just dont know how to make a function that sets the new height and width values to that of what the user has put in ANY help would be GREATLY appreciated!!! thanks -AMMAR Quote Link to comment Share on other sites More sharing options...
Rojay Posted July 11, 2007 Share Posted July 11, 2007 http://www.php.net/manual/en/function.imagecopyresized.php Quote Link to comment Share on other sites More sharing options...
SilentQ-noob- Posted July 11, 2007 Author Share Posted July 11, 2007 K thanks. except, I'm really new to this and I'm not sure how to integrate that code so that it will work for what I want- can you tell me how to get started? Quote Link to comment Share on other sites More sharing options...
Rojay Posted July 12, 2007 Share Posted July 12, 2007 fromt he example on php.com put this code in image.php <?php // File and new size $filename = 'images/click.jpg'; //$percent = 0.5; // Content type header('Content-type: image/jpeg'); // Get new sizes //list($width, $height) = getimagesize($filename); //$newwidth = $width * $percent; //$newheight = $height * $percent; // Load $thumb = imagecreatetruecolor($_GET['width'], $_GET['height']); $source = imagecreatefromjpeg($filename); // Resize imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height); // Output imagejpeg($thumb); ?> and this code in form.php <b>Resized image</b> <? echo "<img src='image.php?width=".$_POST['width']."&height=".$_POST['height']."'>"; ?> Quote Link to comment Share on other sites More sharing options...
SilentQ-noob- Posted July 12, 2007 Author Share Posted July 12, 2007 k thanks a lot, appreciate it! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.