CodeIgniter Forums
correct uploaded images - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: correct uploaded images (/thread-52742.html)



correct uploaded images - El Forum - 06-24-2012

[eluser]Unknown[/eluser]
Hi,
I need to correct a big problem in my webSite: during 1 year we upload 3000 photos. Now with my new deign i need to resize and create 4 images from every uploaded image

exemple:
before:
/images/picture.jpg
/images/thumbs/picture.jpg
Now:
/img/picture.jpg
/img/thumb_picture.jpg
/img/slider_picture.jpg
/img/resized_picture.jpg

So it's clear that we need to select from the data base every picture and move it after duplication to the new folder.

i use image_lib


I know that this code doesnt work. any idea how to resolve this ? thx
Code:
function upload_model(){
        parent::__construct();
        $this->path= realpath(APPPATH."../img");
        $this->min_path= realpath(APPPATH."../upload/images")."\\";
        $this->res_path= realpath(APPPATH."../img/user")."\\";
    }

function correct($url){
        
        


        ////////////////////////////////// thumb
        //http://codeigniter.com/wiki/MY_Image_lib_Extension/
        
        $this->load->library('image_lib');
        $config= array(
            'image_library' => 'gd2',
            'width' => 128,
            'height' => 128,
            'ar_width' => 128,
            'ar_height' => 128,
            'quality' => 100,
            'maintain_ratio' =>true ,
            'source_image' => $photo,
            'new_image' => $this->res_path."medium_".$url
        );
        
      
        
        $this->image_lib->initialize($config);
        $this->image_lib->adaptive_resize();
        ////////////////////////////////////////////// medium
        $config= array(
            'image_library' => 'gd2',
            'width' => 800,
            'height' => 600,
            'quality' => 100,
            'maintain_ratio' =>true ,
            'source_image' => $this->min_path.$url,
            'new_image' => $this->res_path."medium_".$url
        );
        
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
        
        ////////////////////////////////////////////// slide
        $config= array(
            'image_library' => 'gd2',
            'width' => 400,
            'height' => 400,
            'ar_width' => 400,
            'ar_height' => 400,
            'quality' => 100,
            'source_image' => $this->min_path.$url,
            'new_image' => $this->res_path."slide_".$url
        );
        
        $this->image_lib->initialize($config);
        $this->image_lib->resize();
        
        ////////////////////////////////////// micro
        $config= array(
            'image_library' => 'gd2',
            'width' => 64,
            'height' => 64,
            'ar_width' => 64,
            'ar_height' => 64,
            'quality' => 80,
            'maintain_ratio' =>true ,
            'source_image' => $this->min_path.$url,
            'new_image' => $this->res_path."micro_".$url
        );
        
        $this->image_lib->initialize($config);
        $this->image_lib->adaptive_resize();

    }
}