![]() |
Resize and maintain the golden ratio (3:5)? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Resize and maintain the golden ratio (3:5)? (/showthread.php?tid=16004) |
Resize and maintain the golden ratio (3:5)? - El Forum - 02-21-2009 [eluser]markanderson993[/eluser] Hello there CodeIgniter experts! I was wondering if there was a way to crop a picture to a 3:5 ratio? I hope this question was simple! Thanks in advance for any help! ![]() - Pianoman993 Resize and maintain the golden ratio (3:5)? - El Forum - 02-21-2009 [eluser]TheFuzzy0ne[/eluser] Code: function getWidth($height) Supply the height you want to the function and you'll get the right width back. Resize and maintain the golden ratio (3:5)? - El Forum - 02-21-2009 [eluser]markanderson993[/eluser] Thanks for the reply. What if the picture was say 728px by 800px, would this still be able to crop the photo down to a 3:5 dimension? And if the photo was wider than tall it would appear 3 high and 5 long? (and vice-versa) Resize and maintain the golden ratio (3:5)? - El Forum - 02-21-2009 [eluser]TheFuzzy0ne[/eluser] The longest dimension should be used as your master dimension. If the height is the largest dimension: Code: function getWidth($height) If the width is the largest dimension: Code: function getHeight($width) Just bear in mind that the further the image is away from this ratio, the more image you'll lose when it's cropped. Resize and maintain the golden ratio (3:5)? - El Forum - 02-21-2009 [eluser]markanderson993[/eluser] Makes sense to me. Thanks for your help Fuzzy! Resize and maintain the golden ratio (3:5)? - El Forum - 02-21-2009 [eluser]TheFuzzy0ne[/eluser] Sorry, I was wrong. You'd need to crop by the smallest dimension. It's 5:32AM and my brain is not working any more. Code: function getCropDimensions($width, $height) |