Welcome Guest, Not a member yet? Register   Sign In
Image Lib: How to maintain_ratio with MINIMUM short side?
#1

[eluser]Sven Delle[/eluser]
1. I have a thumbnail slot of 32 by 32 pixels
2. I will create thumbnails from both horizontal and vertical images
3. I need to maintain aspect ratio

How do I make sure I don't end up with white space in the thumbnails?

Scenario:
Image: width: 431 pixels, height: 600

Code:
$config['maintain_ratio'] = TRUE;
$config['master_dim'] = 'auto';
$config['width'] = 32;
$config['height'] = 32;

This gives me an image with a height of 32 and a width of ONLY 23.

How do I make sure that I always FILL the whole thumbnail slot wether the image is horizontal or vertical?
#2

[eluser]Silviu[/eluser]
You need to use the crop function.

Grab the image dimensions from the upload class and use them to calculate the coordinates needed for cropping.
#3

[eluser]gRoberts[/eluser]
Take a quick look at http://www.matmoo.com/digital-dribble/co...image_moo/

It's saved me a load of time when dealing with the Image Library in CI...
#4

[eluser]Sven Delle[/eluser]
Thanks, I'm going for the native CI image lib. And I do not want cropping. I'll see what I can come up with.




Theme © iAndrew 2016 - Forum software by © MyBB