CodeIgniter Forums

Full Version: GD Library Need Overlay & Text method together
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]aruntvla[/eluser]
GD Library Need Overlay & Text method together

Hai Friends, How to use GD library with Overlay & Text Both together ...

Controller page

Here iam calling upload function and the resulted image is watermarked...


Code:
$this->load->model('user_createcoupon_model');
                
                 $data = $this->user_createcoupon_model->do_upload();
                 $logo =  $data['upload_data']['file_name'];
                // print_r($logo);
                //print_r($data);
                 // $config['image_library'] = 'gd2';
                 // $config['source_image'] = $logo;
                 // $config['create_thumb'] = TRUE;
                //  $config['maintain_ratio'] = TRUE;
                //  $config['width'] = 75;
                //  $config['height'] = 50;

                 // $this->load->library('image_lib', $config);

                 // $this->image_lib->resize();
                  $this->load->library('image_lib');
                  $config['image_library'] = 'gd2';

                  $config['source_image'] = './uploads/watermark.gif';
                
                  $config['wm_text'] = "$disprice";
                 //$config['wm_type'] = 'text';
                
                 $config['wm_type'] = 'overlay';
                
                 $config['wm_overlay_path'] = './uploads/'.$logo.'';
                  // $config['quality'] = 90%;
                                              
                 //$config['create_thumb'] = TRUE;
                //  
                 // $config['height'] = 10;
                //  $config['wm_font_path'] = './system/fonts/texb.ttf';
                  $config['wm_font_size'] = '15';
                  $config['wm_font_color'] = '#FFFFFF';
                  $config['wm_font_alignment'] = 'middle';
                  $config['wm_vrt_alignment'] = 'T';
                  $config['wm_hor_alignment'] = 'L';
                  $config['wm_padding'] = '50';
                  $config['wm_opacity'] = '100';
                  $config['wm_hor_offset'] = '20';
                  $config['wm_vrt_offset'] = '1';
                  
                  $config['x_axis'] = '50';
                  $config['y_axis'] = '0';
                 // $config2['wm_x_transp'] = '50';


                  $config['new_image'] = './uploads/'.$vendorname.'.gif';
                 // $img = $this->image_lib->resize();

                  $this->image_lib->initialize($config);
                  
                    if ( ! $this->image_lib->watermark())
                    {
                        echo $this->image_lib->display_errors();
                    }
                    
                    $result=$this->image_lib->watermark();
                    $water= ''.$vendorname.'.gif';
                    $str  = $this->user_createcoupon_model->InserData($vendorname,$statename,$category,$regionid,$this->session->userdata('userid'),$water,$postername,$cellno) ;


Model page

Code:
In model page the uploaded image is resized........

      function do_upload()
    {
        $config['upload_path'] = './uploads/';
        $config['allowed_types'] = 'gif|jpg|png';
        $config['max_size']    = '10000000';
        $config['max_width']  = '1024';
        $config['max_height']  = '768';
        $this->load->library('upload', $config);
        if ( ! $this->upload->do_upload())
        {
            $error = array('error' => $this->upload->display_errors());
            echo  $this->upload->display_errors() ;

        }
        else
        {
            $data = array('upload_data' => $this->upload->data());
            $config['image_library'] = 'gd2';
            $config['source_image'] = './uploads/'.$data['upload_data']['file_name'];
          //  $config['create_thumb'] = TRUE;
            $config['maintain_ratio'] = TRUE;
            $config['width'] = 50;
            $config['height'] = 50;
            //print_r($config);

                $this->load->library('image_lib', $config);
               $data = $this->image_lib->resize();
              // echo var_dump(gd_info());
              // $datas = array('message' =>var_dump($this->upload->data()));  
            // $datas = array('resize_data' => $this->image_lib->resize());
             $data = array('upload_data' => $this->upload->data());
            
            // $logo =  $data['upload_data']['file_name'];
            // echo $logo;
            //rename($data['full_path'],'./uploads/'.$newimagename);
            //$pic = realpath('./uploads/'.$newimagename);
            return $data;
            //print_r($datas);
        }
    }


the uploaded image watermarked to another image that stored in uploads folder....after watermarking to that image watermarked text cant displaying why??is thre any idea to use both these water markin methods....if you know please reply???????