Welcome Guest, Not a member yet? Register   Sign In
Image Manipulation Library, Cannot Resize Image.
#1

[eluser]Alfredor[/eluser]
Hello everyone, I'm using the image manipulation library to get an image and create a new resized image in another folder, I have set all proper permissions and the uploading process is working fine, the only thing is that the application is not creating the new image.

controllers/forms.php
Code:
function add_image()
    {
    if($this->dx_auth->is_admin() && $this->input->post('upload')){
    $info = $this->images->do_upload();
    
    $data = array(
    'image' => base_url().'images/pictures/'.$info['file_name'],
    'image_2' => base_url().'images/pictures/thumbs/'.$info['file_name'],
    'description' => $this->input->post('description'),
    'product_id' => $this->input->post('product_id')
    );
    $this->images->add($data);
    }
    redirect('admin/images');
    }

models/images.php
Code:
function do_upload()
    {
    $conf = array(
        'upload_path' => $this->images_path,
        'allowed_types' => 'jpg|jpeg|gif|png',
        'max_size' => '2000',
        'encrypt_name' => TRUE
    );
    $this->load->library('upload',$conf);
    $this->upload->do_upload();    
    $info = $this->upload->data();
    
    $thumb = array(
            'source_image' => $info['full_path'],
            'new_image' => $this->image_path . '/thumbs',
            'maintain_ratio' => TRUE,
            'width' => '150',
            'height' => '150'
    );
    $this->load->library('image_lib',$thumb);
    $this->image_lib->resize();
    return $info;
    }
Quote:Note: Not posting entire script since its not relevant.
#2

[eluser]Mat-Moo[/eluser]
Try to replace the 2nd library load (ignored as library is already loaded) with $this->image_lib->initialize($thumb); You might need a $this->image_lib->clear() first;




Theme © iAndrew 2016 - Forum software by © MyBB