shanelarson55 Posted May 3, 2012 Share Posted May 3, 2012 Hey, I know how to use the PHP GD functions but how would I resize an image > 1000 width to 1000 width and just resizing the height to w/e needed to keep aspect ratio if the image is set to 1000 width in pixels of course. I don't mess with images much so idk the whole ratio thing. Link to comment https://forums.phpfreaks.com/topic/262038-resizing-an-image-without-losing-aspect-ratio/ Share on other sites More sharing options...
xyph Posted May 3, 2012 Share Posted May 3, 2012 It's simple math, and has little to do with 'images' If you want the set width to always be 300 <?php // Source is a 12MP picture $source_width = 4000; $source_height = 3000; $target_width = 300; $ratio = $target_width / $source_width; echo "Our ratio is: $ratio<br>"; $final_width = round($source_width * $ratio); $final_height = round($source_height * $ratio); echo "Our final image will be $final_width x $final_height"; ?> Link to comment https://forums.phpfreaks.com/topic/262038-resizing-an-image-without-losing-aspect-ratio/#findComment-1342831 Share on other sites More sharing options...
shanelarson55 Posted May 3, 2012 Author Share Posted May 3, 2012 Wow that is simple lol, thanks. Link to comment https://forums.phpfreaks.com/topic/262038-resizing-an-image-without-losing-aspect-ratio/#findComment-1342834 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.