download-cloud-line composer require aliamjid/img-cropper

Integration of gumlet/php-image-resize and cropperjs to Nette Froms

How it looks like?

Example of usage Library can be use as Nette control for picking / croping image forexample for profile picture and etc. github flavoured markdown - e.g.

namespace App\Model\Components\UserForm;  
use Gumlet\ImageResize;  
use MS\Entity\UserEntity;  
use MS\Forms\BaseForm;  
class UserForm extends BaseForm {  
  public $id;  
  /** Your constructor etc... */  
  public function defineForm() {  
  $this->addImage('profile_picture','Zvolte obrázek',$this->imageService->getRealPathsFromId($user->profile_picture)->low)  
 ->ignoreAscpectRatioWhileValidate() ->setThumbnailRatio(0.3)  
  public function save($values) {  
  /** @var UserEntity $user */  
  $user = $this->userMapper->loadEntityById($this->id);  
  /** Other stuff */  
 //Check if picture is ok  
 if($values->profile_picture instanceof ImageResize) {  
  //Save picture  
  //$values->profile_picture is [gumlet/php-image-resize] see library for more info
  $user->profile_picture = $this->imageService->saveProfilePicture($values->profile_picture);  
 }  //Do other stuff like updateing database

How to install?

You need to add javascript file to your app

<link rel="stylesheet" href="">

File path is img-cropper/dist/cropper.min.all.js You also need bootstrap and jQuery.

I recommend to also add this to your BaseForm

protected function addImage($name, $label ='',$value = '') {  
return $this[$name] = (new ImageControl($value,$label));  

Now you are ready to use


Dont use nette?

its possible to use it just with normal php. Look at example.php

No release at this moment. Try to create first one.

Componette Componette