Function only executes 1 time

1

I created a% w_that resizes an image that I enter the name, but it's happening that I need the same image to resize to 3 different dimensions, so I made the code

image.php (library)

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Imagem{

    public function GerarImagem($imagem, $largura, $altura){

        $CI =& get_instance();

        $config = array();

        $config['image_library'] = 'gd2';
        $config['source_image'] = 'uploads/'.$imagem;
        $config['new_image'] = 'uploads/'.$altura.'x'.$largura.'_'.$imagem;
        $config['maintain_ratio'] = true;
        $config['width'] = $largura;
        $config['quality'] = "100%";
        $config['height'] = $altura;

        $CI->load->library('image_lib', $config);
        $CI->image_lib->resize();

        return $altura.'x'.$largura.'_'.$imagem;

    }

}
?>

And I call it in library like this:

$miniatura = $this->imagem->GerarImagem($foto_array['file_name'], 110, 110);
$media = $this->imagem->GerarImagem($foto_array['file_name'], 438, 438);
$grande = $this->imagem->GerarImagem($foto_array['file_name'], 720, 720);

The name of the images is inserted right in model , but when doing the resizing it only creates 1 image with the new dimension, which would be the first one I called that was 110x110 the rest does not create in the folder.

    
asked by anonymous 26.03.2016 / 00:02

1 answer

0

Solution

I changed

$CI->load->library('image_lib', $config);

By

$CI->load->library('image_lib');
$CI->image_lib->initialize($config)
    
26.03.2016 / 00:47