• Settings
    • Locale
    • Change the locale of the datepicker, schedule and client side validation messages.

      Language
      English
      English
      English
      French
      German
      German
      German
      Italian
      Korean
      Spanish
      Catalan
      Dutch
      Portuguese
      Portuguese
      Arabic
      Arabic
      Bulgarian
      Bangla
      Bosnian
      Czech
      Greek
      Estonian
      Persian
      Finnish
      Danish
      Hindi
      Indonesian
      Icelandic
      Croatian
      Japanese
      Hungarian
      Hebrew
      Georgian
      Central Kurdish
      Khmer
      Kyrgyz
      Kazakh
      Lithuanian
      Latvian
      Malay
      Norwegian
      Polish
      Romanian
      Russian
      Slovak
      Slovenian
      Serbian
      Serbian
      Swedish
      Thai
      Turkish
      Ukrainian
      Uzbek
      Vietnamese
      Chinese
      Chinese
  • Resources

ImageCropper

ImageCropper can work tightly with FileUpload handling images on the fly.

ImageCropper Tag Documentation

ImageCropper allows cropping a certain region of an image. A new image is created containing the cropped area and assigned to a CroppedImage instanced on the server side.

NameTypeRequiredDefaultDescription
id String false generated Unique identifier of the component in a namingContainer.
rendered boolean false true Boolean value to specify the rendering of the component, when set to false component will not be rendered.
binding UIComponent false generated An EL expression referring to a server side UIComponent instance in a backing bean.
widgetVar String false generated ('widget_' + componentClientId) Name of the client side widget.
alt String false Alternate text of the image.
aspectRatio double false 0.0 Aspect ratio of the cropper area.
boxHeight int false 0 Maximum box height of the cropping area.
boxWidth int false 0 Maximum box width of the cropping area.
cache boolean false true Controls browser caching mode of the resource.
converter Converter false EL expression resolves to a converter instance or literal converter ID defining a component converter.
converterMessage String false
guides boolean false true Show the dashed lines in the crop box.
image Object true Binary data to stream or context relative path.
immediate boolean false false When set true, process validations logic is executed at apply request values phase for this component.
initialCoords String false Initial coordinates of the cropper area (x, y, width,height).
maxSize String false Maximum size of the cropper area (width,height).
minSize String false Minimum size of the cropper area (width,height).
required boolean false false Marks component as required.
requiredMessage String false
responsive boolean false true Re-render the cropper when resizing the window.
sizeLimit Long false 10485760L Maximum number of bytes the image.
submittedValue Object false
validator Validator false A method expression referring to a method validating the input.
validatorMessage String false
value Object false Value of the component.
valueChangeListener ValueChangeListener false A method binding expression referring to a method for handling a valuchangeevent.
viewMode int false 1 Define the view mode of the cropper. ViewMode 0 is not supported. A value of 1, 2 or 3 will restrict the crop box to the size of the canvas. ViewMode of 2 or 3 will additionally restrict the canvas to the container. Note that if the proportions of the canvas and the container are the same, there is no difference between 2 and 3.
zoomOnTouch boolean false true Enable to zoom the image by dragging touch.
zoomOnWheel boolean false true Enable to zoom the image by wheeling mouse.
Loading...
Tag DocumentationNew DocumentationNew Documentation JSDoc Basic Dynamic FileUpload
Choose

Usage


<div class="card">
    <h:form>
        <p:growl id="messages" showDetail="true"/>

        <p:fileUpload mode="advanced"
                      multiple="false"
                      update="messages cropperPanel"
                      listener="#{cropUploaderBean.handleFileUpload}">
            <p:validateFile sizeLimit="102400"
                            allowTypes="/(\.|\/)(gif|jpeg|jpg|png)$/"/>
        </p:fileUpload>

        <p:outputPanel id="cropperPanel">

            <h:panelGrid columns="1" rendered="#{not empty cropUploaderBean.originalImageFile}">

                <p:commandButton value="Crop"
                                 action="#{cropUploaderBean.crop}"
                                 update="cropped messages" styleClass="my-3"/>

                <h:panelGrid columns="2" cellpadding="7">

                    <p:imageCropper value="#{cropUploaderBean.croppedImage}"
                                    id="imageCropper" cache="false"
                                    image="#{cropUploaderBean.image}"
                                    initialCoords="50,50,150,100"
                                    minSize="50,50" maxSize="350,350"/>

                    <p:outputPanel id="cropped">
                        <p:graphicImage cache="false"
                                        rendered="#{not empty cropUploaderBean.croppedImage}"
                                        value="#{cropUploaderBean.cropped}"/>
                    </p:outputPanel>

                </h:panelGrid>

            </h:panelGrid>
        </p:outputPanel>
    </h:form>
</div>