Upload with Watermark using Codelgniter

Asked

Viewed 208 times

1

I am doing an Upload here with Codeigniter, this working perfect, but I can not put a logo as watermark and I would also like to put the address of the site, I do not know why the error.. the code is as follows:...

 /* Upload de imagem: */

 $config['upload_path']   = './tema/dist/img/timeline/';
 $config['allowed_types'] = 'gif|jpg|png';
 $config['max_size']      = '0';
 $config['max_width']     = '0';
 $config['max_height']    = '0';
 $config['encrypt_name']  = true;
 $config['multi']         = 'all';
 $this->load->library('upload', $config); 

 $upload_data = $this->upload->data();

/* Colocar Logo de Marcar D'Agua */
$img_config['wm_type'] = 'overlay';
$img_config['wm_overlay_path'] = './tema/dist/img/layout/logomarcap.png';
$img_config['wm_x_transp'] = 20;
$img_config['wm_y_transp'] = 10;
$img_config['wm_opacity'] = 50;
$img_config['wm_vrt_alignment'] = 'bottom';
$img_config['wm_hor_alignment'] = 'left';
$img_config['source_image'] = $upload_data['full_path'];  
$this->image_lib->initialize($img_config); 
$this->image_lib->watermark();
$this->image_lib->clear();

/* Colocar Nome */
$water['source_image']  = $upload_data['full_path'];
$water['wm_text']       = 'Marcio Vaz';
$water['wm_type']       = 'text';
$water['wm_font_path']  = './system/fonts/texb.ttf';
$water['wm_font_size']  = '12';
$water['wm_font_color'] = 'ffffff';
$water['wm_vrt_alignment'] = 'bottom';
$water['wm_hor_alignment'] = 'right';
$water['wm_padding']       = '20';
$this->image_lib->initialize($water);
$this->image_lib->watermark();
  • Are you giving any errors? The file is going up to the correct folder, so just try to do the first one and show the possible errors with echo $this->image_lib->display_errors();

  • The Watermarking feature requires the GD/GD2 library according to the IC manual

  • 1

    solved.. was the way to call the public that this wrong... $this->load->library('img_lib', $water);

  • Good, just put then as an answer so that the question does not go without an answer!

  • changed the line $this->image_lib->Watermark(); for $this->load->library('img_lib', $water); remembering that you can only work with a watermark type... or image or text... $water['wm_type'] = 'text'; or $water['wm_type'] = 'overlay';

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.