You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Dec 23, 2021. It is now read-only.
Resizing images dynamically to a specific proportion can actually be very strange. A standard configuration is not needed, but a array of parameters is required. It can simply be done like this.
$this->load->library('image_lib');
$config = array(
'image_library' => 'gd2',
'source_image' => '/absolute/path/to/image.png',
'new_image' => '/absolute/path/to/new/image.png',
'maintain_ratio' => true,
'height' => 920,
'width' => 9999999999 // simulate infinity
);
$this->image_lib->initialize($config);
if (!$this->image_lib->resize())
exit('GD2 does not seem to be configured correctly');
$this->image_lib->clear();
Given the above code, use 999999999999999 to simulate infinity on the dimension you want to dynamically scale to the ratio of the other dimension.
If you're resizing multiple photos, you need to make sure you're clearing the image library or it'll retain the original source_image and new_image configuration.