Image resizing - maintain ratio but within boundaries - 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: Image resizing - maintain ratio but within boundaries (/showthread.php?tid=36568) |
Image resizing - maintain ratio but within boundaries - El Forum - 12-06-2010 [eluser]prawn_king[/eluser] Hello! I have a bit of an issue wherein I need to take an uploaded image, resize it a few times for different areas and maintain the ratio, but within a maximum width and height. The image needs to be resized into boxes that are of varying shape - some more or less square, others portrait for example. For display, I'm using CSS to centre the image horizontally/vertically in a div of fixed size but every now and again an image will burst out and be larger than the maximum dimension (happens both for width & height). It seems to be that master_dim will only take into account one or other of the sizes. While I understand that is intentional - I was wondering if there was a way of setting max boundaries? Does any of that make sense? I have a feeling it's too late for me to be fully cohernt, so for that, I apologise! Image resizing - maintain ratio but within boundaries - El Forum - 12-06-2010 [eluser]TaylorOtwell[/eluser] http://phpthumb.gxdlabs.com/ Image resizing - maintain ratio but within boundaries - El Forum - 12-06-2010 [eluser]prawn_king[/eluser] [quote author="TaylorOtwell" date="1291713549"]http://phpthumb.gxdlabs.com/[/quote] Ah. I was hoping to find a way using the CI image library but if not, that looks perfect. Thanks Image resizing - maintain ratio but within boundaries - El Forum - 12-06-2010 [eluser]kaisama[/eluser] Hmm, sounds similar to what I needed done for my application. This is what I came up with, as a function in my gallery model. Maybe you can try and use it for what you need? Will most likely need to change the coding a bit, but it should give you a start :3 Code: function thumbnail($image, $width, $height, $align='', $master_dim='auto') Image resizing - maintain ratio but within boundaries - El Forum - 12-07-2010 [eluser]Mat-Moo[/eluser] Check out image_moo in my sig Image resizing - maintain ratio but within boundaries - El Forum - 12-07-2010 [eluser]prawn_king[/eluser] [quote author="Mat-Moo" date="1291731351"]Check out image_moo in my sig [/quote] Perfick. Exactly what I needed. Image resizing - maintain ratio but within boundaries - El Forum - 12-08-2010 [eluser]Mat-Moo[/eluser] No probs, glad I could help! |