Cropping images
The imageCropper
component provides image-cropping functionality by allowing us to crop a certain region of an image, which could either be a local image or an external image. After cropping, a new image is created. It contains the cropped region and it is assigned to a CroppedImage
instance.
How to do it...
The org.primefaces.model.CroppedImage
class belongs to the PrimeFaces API, and the structure of the class is as follows:
public class CroppedImage { String originalFilename; byte[] bytes; int left; int top; int width; int height; }
A simple definition of the image cropper for cropping a local image would be as shown in the following code line. The value of the component is bound with an instance of CroppedImage
.
<p:imageCropper ...
Get PrimeFaces Cookbook - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.