[eluser]Sanity11[/eluser]
Hi all,
I have a problem with the image manipulation class. To clarify this is the code:
Code:
$upload_info = array('upload' => $this->upload->data());
$new_filename = explode('.', $upload_info['upload']['file_name']);
$new_filename_rs = $new_filename[0] . '_rs.' . $new_filename[1];
$new_filename_wm = $new_filename[0] . '_wm.' . $new_filename[1];
$this->load->library('image_lib');
$config_rs['source_image'] = './images/uploads/' . $upload_info['upload']['file_name'];
$config_rs['maintain_ratio'] = TRUE;
//$config_rs['master_dim'] = 'auto';
$config_rs['width'] = 500;
$config_rs['new_image'] = './images/uploads/' . $new_filename_rs;
$this->image_lib->initialize($config_rs);
$this->image_lib->resize();
$config_rs['new_image'] = './images/uploads/' . $new_filename_wm;
$this->image_lib->initialize($config_rs);
$this->image_lib->resize();
$config_wm['source_image'] = './images/uploads/' . $new_filename_wm;
$config_wm['wm_overlay_path'] = './images/uploads/wm.png';
$config_wm['wm_type'] = 'overlay';
$config_wm['wm_vrt_alignment'] = 'center';
$config_wm['wm_hor_alignment'] = 'center';
$config_wm['dynamic_output'] = FALSE;
$config_wm['create_thumb'] = FALSE;
$this->image_lib->initialize($config_wm);
$this->image_lib->watermark();
$this->od_model->insert_image_data($new_filename_rs, $new_filename_wm);
if (! $this->image_lib->watermark())
{
$upload_info = array('wm_info' => $this->image_lib->display_errors(), 'path' => $data['uploaded_images_path'] . $upload_info['upload']['file_name']);
$this->images($upload_info);
}
else
{
//Als alles klaar is wordt de functie images aageroepen. Deze herlaadt de pagina zodat de updates zichtbaar zijn.
$this->images($upload_info);
}
This code does the following:
-Copy the original uploaded image with a different name and resize to a widht of 500px;
-Make another copy of the original uploaded image with a different filename and resize to a width of 500px;
-Apply a watermark to the second copy.
The aspect ratio of the first image is distorted, only the width is changed to 500, the height is still from the original image.
The second image where the watermark is applied to is correct.
It looks like in the attachment.
Does anyone know how come?