'Codeigniter resizing of image not working
I am trying to resize the uploaded image to height of 163px maintaining aspect ratio and then upload it to a folder. I tried with the following code:
$id=1; // user id
$this->load->library('image_lib');
$filename=$_FILES['file']['name'];
$config['image_library'] = 'gd2';
$config['upload_path'] = './userdata/'.$id;
$config['height'] = '163px';
$config['maintain_ratio'] = TRUE;
//$config['master_dim'] = 'height';
$config['source_image'] = $filename;
$this->load->library('upload', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
if(!$this->upload->do_upload('file'))
{
echo $this->data['error'] = $this->upload->display_errors();
}
However this is uploading the image to the correct folder but the image is not resized. I uploaded an image of size *170*128* and it is uploaded to folder as it is without resizing. What is wrong with my code?
Can anyone help me to find the problem?
Thanks in advance.
Solution 1:[1]
Simple...
You have to do one thing Go to Captcha_helper.php and search
instead of
$x = mt_rand(0, $img_width / ($length / 3));
Do Like this
$x = mt_rand(0, $img_width / ($length / 1));
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Kiran Lohar |
