Please give a option to crop and resize a image while upload, at least a extension that can do it with modula dialog.
Thank you.
Croping and Image Resize while upload
-
- User
- Posts: 86
- Location: Almaty, Kazakhstan
Croping and Image Resize while upload
-
- User
- Posts: 9439
If you have enabled resize in Edit Tag panel, you can use Row_Inserting/Updating server event (see Server Events and Client Scripts in the help file) and add plugin(s) for resizing to the Upload object of the file upload field, e.g.
$this->MyFileUploadField->Upload->Plugins[] = function($thumb) {
$thumb->cropFromCenter(400, 300);
};
The $thumb is an instance of a subclass of GD (extends PHPThumb) class which has crop() and cropFromCenter() and adaptiveResize*() methods (see source code of PHPThumb.php), you can crop and/or resize the image. (Resizing will still be done later according to your project settings.)
-
- User
- Posts: 432
I am using PHPMaker 2022.0.6
I want to upload a Photo and choose the portion to crop as per my requirement
Under Edit Tag -
Resize Image is enabled
under the Server Script -> Table Specific ->Common->Row_Inserting
$this->Photo->Upload->Plugins[] = function($thumb) {
$thumb->cropFromCenter(400, 300);
};
The photo is uploaded and i did not get the option for cropping.
-
- User
- Posts: 9807
It should work. Was the image resized? If so, it should also have been cropped.
Note that cropping by PHPThumb is done on server side after upload, it won't let user "choose the portion to crop". If you use cropFromCenter()
, you need to make sure the users upload images with the portion you need at the center.
Make sure the resized image is larger than the cropping size or there is nothing to crop.
-
- User
- Posts: 9807
This may not be simple, but should be viable. PHPMaker uses jQuery File Upload, which supports processQueue, you should be able to add a process action to call Cropper.js in a modal dialog (see source in the example) for user to crop.