[eluser]Richko[/eluser]
Solved.
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config); // Just added this line. Magic?
Code:
<?php
Class Gallery_model extends Model {
private $gallery_path;
function Gallery_model() {
parent::Model();
$this->gallery_path = realpath(APPPATH . '../public/upload/gallery');
}
function do_upload() {
$config = array(
'allowed_types' => 'jpg|jpeg|gif|png|x-png',
'upload_path' => $this->gallery_path,
'max_size' => 2000
);
$this->load->library('upload', $config);
$this->upload->initialize($config);
$this->upload->do_upload();
$image_data = $this->upload->data();
// resize
$config = array(
'image_library' => 'GD2',
'source_image' => $image_data['full_path'],
'new_image' => $this->gallery_path . '/resized',
'maintain_ratio' => TRUE,
'width' => 800,
'height' => 600
);
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
$this->image_lib->clear();
// thumb
$config = array(
'image_library' => 'GD2',
'source_image' => $image_data['full_path'],
'new_image' => $this->gallery_path . '/thumbs',
'create_thumb' => TRUE,
'thumb_marker' => '_thumb',
'maintain_ratio' => TRUE,
'width' => 100,
'height' => 100
);
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
}
?>