I am using the image library in Codeigniter to resize my image. I notice that CI only resizes the image to fit inside the specified dimensions: A 50px by 50px image resized to fit a 30px by 20px box will be resized to 20px by 20px and leaves a black area for the empty space.
What I want is to resize such that the resize image fills the entire 30px by 30px space with the excess portion being cropped out.
Is this possible in Codeigniter?
I think you’ll need to resize the image first, choosing either width or height as the “master” dimension, then crop it.
I haven’t tested this code, but give it a shot. If nothing else, it should give you the idea.
You may want to try to center the crop dimensions instead. Whichever way you choose to do it, the image needs to be cropped at some point.
I should note that I’m not sure if
$config['height'] = 0is the right way to ignore height, it might have to beFALSE, a really high number, or removed altogether (haven’t worked with the CI image lib in a while).