CodeIgniter Forums
Resize image only when it is too big - 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 image only when it is too big (/showthread.php?tid=10084)



Resize image only when it is too big - El Forum - 07-18-2008

[eluser]Unknown[/eluser]
I want to resize image only when it is to big, and leave it unchanged, when width and height are proper. How can I do this using CI Image library?


Resize image only when it is too big - El Forum - 07-18-2008

[eluser]Bramme[/eluser]
you'll have to do the calculations yourself...
Code:
$image_url = '/myimage.jpg';
$max_size = 500px;

list($width, $height, $t, $i) = getimagesize($image_url);
if($width > $max_size || $height > $max_size) {
    // use image lib
}