[eluser]Soares[/eluser]
Hello guys!
I found myself recently with a problem that I couldn't find a solution. Actually, my code was working and suddenly it has stopped.
Well.. The problem is:
I have an image upload form. After doing the upload (which is working okay) I got to create two thumbs - one with 500px and another with 100px. I don't know what I've changed, but now it just not works for certain images. For example, if I upload and image of 250 KB, the thumbs creation works perfectly. On the other hand, if I upload an image of 2MB, the thumbs are not created (although the upload still works).
What might be causing it?
Here is the thumb creation code:
Code:
/**
* criarThumbs()
* Após o upload ter sido efetuado, essa função é responsável por criar os thumbnails (big e mini). Arquivos
* do tipo .bmp não são suportados.
*
**/
function criarThumbs($info)
{
$this->load->library('image_lib');
$config['image_library'] = 'gd2';
$config['source_image'] = $info['full_path'];
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
// mini_thumb
$config['new_image'] = $info['file_path'] . '_mini_thumbs/'; // sem dizer o nome do arquivo. É automático.
$config['width'] = 150;
$config['height'] = 120;
$config['quality'] = 100;
$this->image_lib->initialize($config);
log_message('debug', '[painel_acoes] Classe inicializada');
echo "\nCriando mini_thumb: ";
if ( ! $this->image_lib->resize())
{
echo "Erro:".$this->image_lib->display_errors();
}
else
{
echo "OK";
}
$this->image_lib->clear();
// big_thumb
$config['new_image'] = $info['file_path'] . '/_big_thumbs/';
$width = 600;
$height = 500;
$config['width'] = $width;
$config['height'] = $height;
$config['quality'] = 100;
$this->image_lib->initialize($config); // inicia novamente, com as novas configurações do big_thumb.
echo "\nCriando big_thumb: ";
if ( ! $this->image_lib->resize())
{
echo "Erro:".$this->image_lib->display_errors();
}
else
{
echo "OK";
}
}
The variable $info is an array containing the following information:
Code:
Array
(
[file_name] => mypic.jpg
[file_type] => image/jpeg
[file_path] => /path/to/your/upload/
[full_path] => /path/to/your/upload/jpg.jpg
[raw_name] => mypic
[orig_name] => mypic.jpg
[file_ext] => .jpg
[file_size] => 22.2
[is_image] => 1
[image_width] => 800
[image_height] => 600
[image_type] => jpeg
[image_size_str] => width="800" height="200"
)
Anybody has a tip of what might be happening?
Thanks in advance!