Welcome Guest, Not a member yet? Register   Sign In
image_lib Class problem
#1

[eluser]Unknown[/eluser]
I'm trying to resize various sized images to 416x243. I figured that I have to resize it as far as I can and then to crop as needed, but I can'd to it. I'm here :

Code:
# Looping through files
  foreach($scan as $file)
  {  
   # Checking if thumb exists
   if(!file_exists($thumbs_folder . '/' . $file) && $file != 'thumbs')
   {
    # Checking if thumb dir exists
    # if not, attempt to create it
    if(!is_dir($thumbs_folder)) mkdir($thumbs_folder);

    # Loading the Image Manipulation Library
    $this->load->library('image_lib');
    
    # Resizing configuration
    $config['source_image'] = $full_path . '/' . $file; // The source image - full path / file
    $config['new_image'] = $thumbs_folder;    // The thumbs folder
    $config['create_thumb'] = FALSE;     // Create thumb /boolean/
    $config['maintain_ratio'] = TRUE;     // Weither to maintain ratio or not /boolean/
    $config['width'] = 416;        // The width of the new image
    $config['height'] = 243;       // The height of the new image
    $config['master_dim'] = 'width';     // Use width as hard value

    # Initialising the library with the configuration settings
    $this->image_lib->initialize($config);
    
    if(!file_exists($full_path . '/' . $file)) show_error('File does not exists!');
    
    # Resizing
    if(!$this->image_lib->resize())
    {
     # Something is wrong, show error
     show_error($this->image_lib->display_errors());
    }
    
    # Clearing configuration
    $this->image_lib->clear();
    
    # Croping configuration
    $config['source_image'] = $thumbs_folder . '/' . $file;
    $config['news_image'] = $thumbs_folder . '/' . $file;
    $config['x_axis'] = 0;
    $config['y_axis'] = 0;
    
    
    # Initialising the library with the new settings;
    $this->image_lib->initialize($config);
    
    # Croping
    if(!$this->image_lib->crop())
    {
     # Something is wrong, show error
     show_error($this->image_lib->display_errors());
    }
   }




Theme © iAndrew 2016 - Forum software by © MyBB