Welcome Guest, Not a member yet? Register   Sign In
Square images and centered thumbs with image_lib
#1

[eluser]Unknown[/eluser]
Hi all i'm trying cropping then resizing images for create thumbs .... i don't think my lib crop() functions still working cause i see images only resized at 80x80 px but not cropped first Sad

no errors from echo $this->image_lib->display_errors() returns Sad

i would like to ... first (according to original $imgWidth and $imgHeight) crop them and make them squared , then resize them to a fixed thumb dimension (80x80px) .... but seems something wrong with cropping still not working maybe !? Sad


Code:
$this->load->library('image_lib');
                      if($imgWidth > $imgHeight){
                      $img['image_library'] = 'gd2';
                      $img['source_image'] = 'uploads/img/gallery/small/'.$photo;
                      $img['maintain_ratio'] = FALSE;
                      $img['x_axis'] = $imgWidth - $imgHeight;
                      $img['y_axis'] = $imgHeight;
                      $this->image_lib->initialize($img);
                      $this->image_lib->crop();

                      echo $this->image_lib->display_errors();
                      
                      }
                       if($imgWidth < $imgHeight){
                      $img['image_library'] = 'gd2';
                      $img['source_image'] = 'uploads/img/gallery/small/'.$photo;
                      $img['maintain_ratio'] = FALSE;
                      $img['x_axis'] = $imgWidth;
                      $img['y_axis'] = $imgHeight-$imgWidth;
                      $this->image_lib->initialize($img);
                      $this->image_lib->crop();

                      echo $this->image_lib->display_errors();
                      
                      }
                      $img['image_library'] = 'gd2';
                      $img['source_image'] = 'uploads/img/gallery/small/'.$photo;
                      $img['maintain_ratio'] = FALSE;
                      $img['width'] = 80;
                      $img['height'] = 80;
                      $this->image_lib->initialize($img);
                      $this->image_lib->resize();
                      echo $this->image_lib->display_errors();
check this code someone have any idea? Sad
#2

[eluser]Team Kulafihi[/eluser]
Here is a very well explained tutorial on file uploading and image manipulation. Hope will be of help. Codeigniter From Scratch




Theme © iAndrew 2016 - Forum software by © MyBB