dearmoawiz Posted May 2, 2008 Share Posted May 2, 2008 hi guys hwz u all .... can any body tell me how we resize an image in php ?? need urget response enjoy !!!! wizzz Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/ Share on other sites More sharing options...
jonsjava Posted May 2, 2008 Share Posted May 2, 2008 oh kay effin youz gonna tawk liek tes no Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531697 Share on other sites More sharing options...
dearmoawiz Posted May 2, 2008 Author Share Posted May 2, 2008 wts tht buddy? Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531699 Share on other sites More sharing options...
bluebutterflyofyourmind Posted May 2, 2008 Share Posted May 2, 2008 you can do a simple resize using html in the image tags <img src="" height=xx width=xx /> This is useful for making thumbnails though dependnig on the size of the image, they may take a while to load. also the width and height you would need to calculate to keep them proportional. If you want to resize an image say for upload, before y ou save it to the server you have to go through a more complex process. does the simpler method above suffice? or to you need to resize the image being saved to a server? what is your situation? Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531700 Share on other sites More sharing options...
dearmoawiz Posted May 2, 2008 Author Share Posted May 2, 2008 i need to resize the image being saved on server ... infact the real scenario is that i wanna build a photo album in php so there if i upload images i want that they resized in equal size and then saved on server ... so tht the real scenario did u got my point??? Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531703 Share on other sites More sharing options...
jonsjava Posted May 2, 2008 Share Posted May 2, 2008 ah, I gotcha. There are 2 ways you can do this: 1: use an open-source solution like ImgUpload or 2: learn the image libraries built into PHP. I figured you would be more interested in reverse-engineering ImgUpload, though. Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531705 Share on other sites More sharing options...
jonsjava Posted May 2, 2008 Share Posted May 2, 2008 and if you want your own script to handle it: <?php /* WARNING: This version only works with JPG files */ $img = //Your image stuff goes here (according to how you are posting the data) //Percent you want it to resize to $percent = 0.75; // Load image $image = open_image(img); if ($image === false) { die ('Unable to open image'); } // Get original width and height $width = imagesx($image); $height = imagesy($image); // New width and height $new_width = $width * $percent; $new_height = $height * $percent; // Resample $image_resized = imagecreatetruecolor($new_width, $new_height); imagecopyresampled($image_resized, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); // Display resized image header('Content-type: image/jpeg'); imagejpeg($image_resized); die(); ?> Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531706 Share on other sites More sharing options...
litebearer Posted May 2, 2008 Share Posted May 2, 2008 also might look here... http://www.nstoia.com/toh/technical/imageresize/index.php Lite... Link to comment https://forums.phpfreaks.com/topic/103872-how-to-resize-an-image/#findComment-531721 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.