Welcome Guest, Not a member yet? Register   Sign In
how to check width and height of image before resize
#1

[eluser]Tống Kiện Phi[/eluser]
In the example Image Manipulation Class i saw this code:

Code:
$config['image_library'] = 'gd2';
$config['source_image'] = '/path/to/image/mypic.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width']  = 75;
$config['height'] = 50;

$this->load->library('image_lib', $config);

$this->image_lib->resize();

Now, i want to check size image if width more than 150px it's must resize, on the contrary not resize
#2

[eluser]NotDior[/eluser]
http://php.net/getimagesize - Would be your best bet.
#3

[eluser]memVN[/eluser]
Ok
When you was uploaded success - function upload will return an array as $upload = $this->upload->data();

In array $upload you has key $upload['width'];

So in order to check width before resize you can do like

if($upload['width'] > 150)
{
//Do resize
}




Theme © iAndrew 2016 - Forum software by © MyBB