s4salman Posted February 7, 2009 Share Posted February 7, 2009 Dear i am using the script attcahed, i have some photos in 1600x1200 size. When i craete thumbnails using this script, it uploads 1600x1200 size image on the server. Also it craetes 1024x768 and 800x600 size dynamically. But i also want to create 640x480 pixel image. How can i do this.What additional code in need to put in it. Please help [attachment deleted by admin] Quote Link to comment Share on other sites More sharing options...
landavia Posted February 7, 2009 Share Posted February 7, 2009 after review your code i think.. you need to put the procedure script on other page Quote Link to comment Share on other sites More sharing options...
s4salman Posted February 7, 2009 Author Share Posted February 7, 2009 Landavia, i did not got your point. Quote Link to comment Share on other sites More sharing options...
landavia Posted February 8, 2009 Share Posted February 8, 2009 Landavia, i did not got your point. <?php if(isset($_POST['submit'])){ if (isset ($_FILES['new_image'])){ $imagename = $_FILES['new_image']['name']; $source = $_FILES['new_image']['tmp_name']; $target = "images/".$imagename; move_uploaded_file($source, $target); $imagepath = $imagename; $save = "images/" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 1024; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; $save = "images/sml_" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file list($width, $height) = getimagesize($file) ; $modwidth = 800; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; } } ?><form action="<?php echo $_server['php-self']; ?>" method="post" enctype="multipart/form-data" id="something" class="uniForm"> <input name="new_image" id="new_image" size="30" type="file" class="fileUpload" /> <button name="submit" type="submit" class="submitButton">Upload/Resize Image</button> </form> <?php if(isset($_POST['submit'])){ echo "Large image: <img src='images/".$imagepath."'><br>"; echo "Thumbnail: <img src='images/sml_".$imagepath."'>"; } ?> about the script u combine all form and resize script on 1 file.. well that's nice but good.. btw.. u ask >>What additional code in need to put in it. u already built it.. u just change the value into 640 like below list($width, $height) = getimagesize($file) ; $modwidth = 640; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; Quote Link to comment Share on other sites More sharing options...
s4salman Posted February 8, 2009 Author Share Posted February 8, 2009 Dear when i added this code : list($width, $height) = getimagesize($file) ; $modwidth = 640; $diff = $width / $modwidth; $modheight = $height / $diff; $tn = imagecreatetruecolor($modwidth, $modheight) ; $image = imagecreatefromjpeg($file) ; imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; [code] it is now only generating 640x480 size image.and original file is uploading. it is not generating 800x600 size image. Quote Link to comment Share on other sites More sharing options...
landavia Posted February 9, 2009 Share Posted February 9, 2009 i think i miss this one $save = "images/sml640_" . $imagepath; //This is the new file you saving $file = "images/" . $imagepath; //This is the original file before my code above 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.