Welcome Guest, Not a member yet? Register   Sign In
Image_lib
#1

[eluser]Paulodemoc[/eluser]
Hey folks... i seem to have a problem while working with images using image_lib...
I upload a image and create a thumb. If the thumb is bigger than 150x75, i crop it.
But if I upload like 5 images, it creates the thumb for the first, but not for the
others... The others are resized and cropped on the original image... I already tryied to insert $this->image_lib->clear(); and unset($config); Here is the code:

Code:
function _createThumb($image) {
        $this->image_lib->clear();
        unset($config);
        $config['image_library']        =       'gd2';
        $config['source_image']         =       $this->folder.'/'.$image;
        $config['create_thumb']         =       TRUE;
        $config['maintain_ratio']       =       TRUE;
        $config['master_dim']           =       'width';
        $config['width']                =       150;
        $config['height']               =       75;
        
        $this->image_lib->initialize($config);
        if (!$this->image_lib->resize()) {
            return $this->image_lib->display_errors();
        }
        else {
                    return "Success";
        }
    }


and the following inside a loop:

Code:
if ($this->_createThumb($foto['img'])) {
                                  $explode              =        explode(".",$foto['img']);
                                  $foto['thumb']           =        $explode[0].'_thumb.'.$explode[1];
                                  $foto['thumb_url']    =        base_url().$this->folder.$foto['thumb'];
                                  $new_file             =        getimagesize($this->folder.$foto['thumb']);
                                  if($new_file[0] > 150 /*width*/ || $new_file[1] > 75 /*height*/) {
                                    unset($config);
                                    $this->image_lib->clear();
                                    $config['image_library']        = 'gd2';
                                    $config['source_image']         = $this->folder.$foto['thumb'];
                                    $config['create_thumb']         = FALSE;
                                    $config['maintain_ratio']       = FALSE;
                                    $config['height']               = 75;                
                                    $config['width']                = 150;
                                    $config['x_axis']               = ($new_file[0]/2) - (150/2);
                                    $config['y_axis']               = ($new_file[1]/2) - (75/2);
                                        
                                    $this->image_lib->initialize($config);
                                    $this->image_lib->crop();
                                  }
                              }

Anyone might know what is going on?




Theme © iAndrew 2016 - Forum software by © MyBB