Welcome Guest, Not a member yet? Register   Sign In
image manipulation problem
#2

[eluser]Richko[/eluser]
Solved.
$this->load->library('image_lib', $config);
$this->image_lib->initialize($config); // Just added this line. Magic? Smile

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();
    }

}

?>


Messages In This Thread
image manipulation problem - by El Forum - 01-12-2011, 11:55 AM
image manipulation problem - by El Forum - 01-12-2011, 12:09 PM
image manipulation problem - by El Forum - 03-22-2011, 06:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB