• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Image lib watermark strange behavior

#1
Not sure if I found a bug or if I'm using the image lib class wrong but I am making a thumb from an uploaded image and then creating another image from that thumb with a watermark and the watermark always gets all buggered up. Maybe because the watermark is bigger than the image?

Full code to replicate:

Code:
public function index() {

       $this->load->helper('form');

       echo $this->session->message . '<br>';
       $this->session->unset_userdata('message');

       echo form_open_multipart('/neou_cms/test/submit');
       echo form_upload('IMG');
       echo form_submit(array('value' => "Submit"));
   }

   public function submit() {

       //if (!empty($_FILES['IMG']['tmp_name'])) {
       $upload["upload_path"] = "./uploads/";
       $upload["allowed_types"] = "gif|jpg|png|jpeg";
       $upload["max_size"] = "20444448";
       $upload["encrypt_name"] = true;
       $this->load->library("upload", $upload);
       if ($this->upload->do_upload('IMG')) {
           $photo = $this->upload->data();
           //$row1['photo'] = $photo['file_name'];
           //$this->ads_photos->create($row1);
           $this->load->library('image_lib');
           //make image smaller
           $config1['image_library'] = 'gd2';
           $config1['source_image'] = './uploads/' . $photo['file_name'];
           $config1['create_thumb'] = true;
           $config1['thumb_marker'] = '_thumb';
           //$config1['master_dim'] = 'auto'; // DEFAULT IS ALREADY AUTO
           $config1['quality'] = '70%';
           $config1['new_image'] = './uploads/cars-list/' . $photo['file_name'];
           $config1['width'] = '700';
           $config1['height'] = '300';
           
           $this->image_lib->initialize($config1);
           $this->image_lib->resize();
           $this->image_lib->clear();

           //$config2['image_library'] = 'gd2';
           $config2['source_image'] = './uploads/cars-list/' . $photo['raw_name'] . $config1['thumb_marker']. $photo['file_ext'];
           
           $config2['wm_type'] = 'overlay';
           $config2['wm_overlay_path'] = './uploads/watermark.png';
           $config2['wm_opacity'] = 60;
           $config2['wm_vrt_alignment'] = 'bottom';
           $config2['wm_hor_alignment'] = 'right';
           
           //$config2['thumb_marker'] = '_watermarked'; // !important (otherwise overwright)
           //$config2['create_thumb'] = true;
           $config2['new_image'] = './uploads/cars-list/' . $photo['raw_name'] . '_watermarked'. $photo['file_ext'];
           //$config2['width'] = '400';
           //$config2['height'] = '250';
           //$this->image_lib->clear();
           $this->image_lib->initialize($config2);
           //$this->image_lib->resize();

           if (!$this->image_lib->watermark()) {
               echo $this->image_lib->display_errors();
               //$this->session->set_userdata('message', $this->image_lib->display_errors());
           }
           //the rest of code is adding the images to database
       } else {
           echo $this->upload->display_errors();
           //$this->session->set_userdata('message', $this->upload->display_errors());
       }
       //redirect('/neou_cms/test');
       //}
   }

Output images attached (minus the "main" one as it is quite large).


Attached Files Thumbnail(s)
           
Reply

#2
(03-06-2018, 01:38 PM)alex.fagard Wrote: Maybe because the watermark is bigger than the image?

Looks very much like it.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.