Welcome Guest, Not a member yet? Register   Sign In
correct uploaded images
#1

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

    }
}




Theme © iAndrew 2016 - Forum software by © MyBB