[eluser]Paulodemoc[/eluser]
Hello all...
I am having some trouble with image manipulation =/
I upload the picture, resize it and create a thumb...
But the problem is: if I upload two pictures at the same time, picture 1 is created and so is its thumb, but the second thumb actually is a copy of the first picture =/
But if I upload one picture at a time, it works perfectly...
The code I am using:
Code:
if($_FILES["lagence_cover"]['name'] != '')
{
$_FILES["lagence_cover"]['name'] = $this->_removeAccents($_FILES["lagence_cover"]['name']);
$file_image = $this->_uploadFile("lagence_cover",'gif|jpg|png',$this->width,$this->height);
if (!is_array($file_image)) {
$mannequin['lagence_cover'] = $m->lagence_cover;
$mannequin['lagence_thumb'] = $m->lagence_thumb;
$this->session->set_userdata('errormsg',lang('error_upload_image'));
}
else {
$mannequin['lagence_cover'] = $file_image['file'];
if ($this->_createThumb($mannequin['lagence_cover'],$this->thumb_width,$this->thumb_height)) {
$explode = explode(".",$mannequin['lagence_cover']);
$mannequin['lagence_thumb'] = $explode[0].'_thumb.'.$explode[1];
$new_file = getimagesize($this->folder.$mannequin['lagence_thumb']);
if($new_file[0] > $this->thumb_width || $new_file[1] > $this->thumb_height)
{
unset($configCropThumb);
$this->image_lib->clear();
$configCropThumb['image_library'] = 'gd2';
$configCropThumb['source_image'] = $this->folder.$mannequin['lagence_thumb'];
$configCropThumb['create_thumb'] = FALSE;
$configCropThumb['maintain_ratio'] = FALSE;
$configCropThumb['height'] = $this->thumb_height;
$configCropThumb['width'] = $this->thumb_width;
$configCropThumb['x_axis'] = ($new_file[0]/2) - ($this->thumb_width/2);
$configCropThumb['y_axis'] = ($new_file[1]/2) - ($this->thumb_height/2);
$this->image_lib->initialize($configCropThumb);
$this->image_lib->crop();
}
}
}
} else {
$mannequin['lagence_cover'] = $m->lagence_cover;
$mannequin['lagence_thumb'] = $m->lagence_thumb;
}
...
if($_FILES["collections_cover"]['name'] != '')
{
$_FILES["collections_cover"]['name'] = $this->_removeAccents($_FILES["collections_cover"]['name']);
$file_image = $this->_uploadFile("collections_cover",'gif|jpg|png',$this->width,$this->height);
if (!is_array($file_image)) {
$mannequin['collections_cover'] = $m->collections_cover;
$mannequin['collections_thumb'] = $m->collections_thumb;
$this->session->set_userdata('errormsg',lang('error_upload_image'));
}
else {
$mannequin['collections_cover'] = $file_image['file'];
if ($this->_createThumb($mannequin['collections_cover'],$this->thumb_width,$this->thumb_height)) {
$explode = explode(".",$mannequin['collections_cover']);
$mannequin['collections_thumb'] = $explode[0].'_thumb.'.$explode[1];
$new_file = getimagesize($this->folder.$mannequin['collections_thumb']);
if($new_file[0] > $this->thumb_width || $new_file[1] > $this->thumb_height)
{
unset($configCropThumb);
$this->image_lib->clear();
$configCropThumb['image_library'] = 'gd2';
$configCropThumb['source_image'] = $this->folder.$mannequin['collections_thumb'];
$configCropThumb['create_thumb'] = FALSE;
$configCropThumb['maintain_ratio'] = FALSE;
$configCropThumb['height'] = $this->thumb_height;
$configCropThumb['width'] = $this->thumb_width;
$configCropThumb['x_axis'] = ($new_file[0]/2) - ($this->thumb_width/2);
$configCropThumb['y_axis'] = ($new_file[1]/2) - ($this->thumb_height/2);
$this->image_lib->initialize($configCropThumb);
$this->image_lib->crop();
}
}
}
} else {
$mannequin['collections_cover'] = $m->collections_cover;
$mannequin['collections_thumb'] = $m->collections_thumb;
}
Can someone try and help me? I have no Idea what might be going on...
I'll post the Upload and Create Thumb functions, 'cause I couldn't paste it here...