Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to watermark image usimg Qimage component in cakephp

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 536
    Comment on it

    For watermarking image using Qimage component in cakephp first we have to  download Qimage plugin  after downloading Qimage plugin we have to put it into  App/Controller/Component .

    Then we have to do all this in our controller.

        class UploadsController extends AppController {    
            public function add(){
                 if ($this->request->is('post')) {
                    $this->Upload->create();
                 
              if ($this->request->data['Upload']['photo']!='' && is_array($this->request->data['Upload']['photo'])) {
                    $imgData = array();
                    $imgData['file'] = $this->request->data['Upload']['photo'];
                    $imgData['name']=$this->data['Upload']['photo']['name'];
                    $imgData['path'] = WWW_ROOT . '' . '/images/'; // path where the image will we copied
                    
                    $user_image = $this->Qimage->copy($imgData); //Qimage copy function
                    
                      // Qimage watermark function,
                   $this->Qimage->watermark(
    	array(
    		'file' => $imgData['path'].$user_image,
                    'output' => WWW_ROOT. '/images/thumbnail/' 
                           // path where the image will we uploaded after getting watermark
              )
            );
                }
              else{
                    $user_image = "";
              }
                 
                
            }
    

     

    In above code firstly we are copying our image with the help of $this->Qimage->copy(); function  in our webroot/images folder after copying we are watermarking image with the help of $this->Qimage->watermark(); function and then storing it in webroot/images/thumbnail folder.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: