[eluser]Unknown[/eluser]
Hi guys ,
clear() function doesnt reset the object variables to default ,instead it just
resets them to empty strings, so i had to add myclear function to reset the variables to default otherwise after resize() clear() watermark() , watermarked image hasnt been created.
Code:
private function resize_image($filename)
{
$info = pathinfo($filename);
$rawname = basename($filename,'.'.$info['extension']);
$img_directory = $this->config->item('resim_klasoru');
$fullpath = $img_directory.$filename;
$this->image_lib->myclear(); // clear()
$config['image_library'] = 'gd2';
$config['source_image'] = $fullpath;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 112;
$config['height'] = 63;
$config['dynamic_output'] = FALSE;
$config['new_image'] = $img_directory.$rawname.'_new.'.$info['extension'];
$this->image_lib->initialize($config);
$this->image_lib->resize();
echo $this->image_lib->display_errors();
//unlink('./images/4_tmb.jpg');
//$config['resim_klasoru'] = './images/'
//
//make thumbnail
return $rawname.'_new.'.$info['extension'];
}
Code:
private function create_watermark($filename)
{
$info = pathinfo($filename);
$rawname = basename($filename,'.'.$info['extension']);
$img_directory = $this->config->item('resim_klasoru');
$fullpath = $img_directory.$filename;
$this->image_lib->myclear(); //clear()
$config['image_library'] = 'gd2';
$config['source_image'] = $fullpath;
$config['create_thumb'] = FALSE;
$config['dynamic_output'] = FALSE;
$config['wm_type'] = 'overlay';
$config['wm_hor_offset'] = '-176';
$config['wm_vrt_offset'] = '20';
$config['wm_overlay_path'] ='./static_images/playbutton.png';
$config['wm_padding'] = '0';
$config['new_image'] = $img_directory.$rawname.'_new_watermark.'.$info['extension'];
$config['width'] = 560;
$config['height'] = 315;
$this->image_lib->initialize($config);
$this->image_lib->watermark();
echo $this->image_lib->display_errors();
return $rawname.'_new_watermark.'.$info['extension'];
}