Make 2 sketches at once in codeigniter

can someone tell me how to create 2 different thumbnails of the same images with different sizes and layout in the codegameter. I created a download function and another thumbnail generation function, it works fine, but cannot figure out how to create 2 different icons at once. Any help would be appreciated.

+3
source share
3 answers

This is actually pretty simple ...

function create_thumbs()
{
    $this->load->library('image_lib');

    $path = "path/to/image/";

    $source_image = "original.jpg";
    $medium_image = "medium.jpg";
    $small_image = "small.jpg";

    // Resize to medium

    $config['source_image'] = $path.$source_image;
    $config['new_image'] = $path.$medium_image;
    $config['width'] = 200;
    $config['height'] = 200;

    $this->image_lib->initialize($config); 

    if ( ! $this->image_lib->resize())
    {
        // an error occured
    }

    // Keep the same source image

    $config['new_image'] = $path.$small_image;
    $config['width'] = 50;
    $config['height'] = 50;

    $this->image_lib->initialize($config); 

    if ( ! $this->image_lib->resize())
    {
        // an error occured
    }
}
+12
source

So, you have the thumbnail_generator function and say that it takes the parameters original_file_name, new_file_name and thumbnail_size.

Just call twice!

thumbnail_generator( original_file.jpg, new_file_sm.jpg, 300 );
thumbnail_generator( original_file.jpg, new_file_xsm.jpg, 150 );
+4
source

. .

$this->load->library('image_lib');
$this->image_lib->clear();

0

Source: https://habr.com/ru/post/1743781/


All Articles