Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • Qimage Component in cakephp

    • 0
    • 1
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 522
    Comment on it

    Qimage Component:

    It is used to upload and manipulate images. It can be easily downloaded from github. We can crop or resize image using Qimage crop(), resize() methods.

    Some of the methods of Qimage component:

    copy : copy() method is used to Copy uploaded images.

    resize : resize() method is used to Resize an image.

    watermark : Add watermark in an image.

    crop : Crop an image.

    Example:

    public function upload() {
    			
    		if ($this->request->is('post')) {
    
    	       	$this->Upload->create();
    	       
    	        if ($this->request->data['Upload']['image']!='' && is_array($this->request->data['Upload']['image'])) {
    			$imgData = array();
    			$imgData['file'] = $this->request->data['Upload']['image'];
    			$imgData['name']=$this->data['Upload']['image']['name'];
    
    			$imgData['path'] = WWW_ROOT . '' . '/images/';
    			// echo '<pre>';print_r($imgData);die;
    			$user_image = $this->Qimage->copy($imgData);
    			$this->Qimage->resize(array('height' => 100, 'width' => 100, 'file' => $imgData['path'].$user_image, 'output' => WWW_ROOT . '' . '/images/'));
    			$this->Qimage->crop(array('w' => 50, 'h' => 60, 'x'=>243,'y'=>100,'file' => $imgData['path'].$user_image, 'output' => WWW_ROOT . '' . '/images/'));
    
    			}
    			else{
    			$user_image = "";
    			}
    
    			$fetch['image']=$user_image;
    
    			
    	        
    	        if ($this->Upload->save($fetch)) {
    	        	
    	            echo ('Your post has been saved.');
    	            $this->redirect('display');
    	        } else {
    	            echo('Unable to add your post.');
    	        }
    
                   $file_tmp_name = $this->request->params['form']['driver_image']['tmp_name'];
    
                        
                    
    	    }
    	}

     

 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: