Class CropFilter

  • All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Filter, javax.servlet.FilterConfig

    public class CropFilter
    extends ScaleFilter
    This Servlet is able to render a cropped part of an image.
    Parameters:
    cropX
    integer, the new left edge of the image.
    cropY
    integer, the new top of the image.
    cropWidth
    integer, the new width of the image.
    cropHeight
    integer, the new height of the image.
    cropUniform
    boolean, wether or not uniform scalnig should be used. Default is true.
    cropUnits
    string, one of PIXELS, PERCENT. PIXELS is default.
    image
    string, the URL of the image to scale.
    scaleX
    integer, the new width of the image.
    scaleY
    integer, the new height of the image.
    scaleUniform
    boolean, wether or not uniform scalnig should be used. Default is true.
    scaleUnits
    string, one of PIXELS, PERCENT. PIXELS is default.
    scaleQuality
    string, one of SCALE_SMOOTH, SCALE_FAST, SCALE_REPLICATE, SCALE_AREA_AVERAGING. SCALE_DEFAULT is default.

    Examples:
    <IMG src="/crop/test.jpg?image=http://www.iconmedialab.com/images/random/home_image_12.jpg&cropWidth=500&cropUniform=true">
    <IMG src="/crop/test.png?cache=false&image=http://www.iconmedialab.com/images/random/home_image_12.jpg&cropWidth=50&cropUnits=PERCENT">

    Version:
    $Id: CropFilter.java#1 $
    Author:
    Harald Kuhr, last modified by $Author: haku $
    See Also:
    Serialized Form
    • Field Detail

      • PARAM_CROP_X

        protected static final java.lang.String PARAM_CROP_X
        cropX
        See Also:
        Constant Field Values
      • PARAM_CROP_Y

        protected static final java.lang.String PARAM_CROP_Y
        cropY
        See Also:
        Constant Field Values
      • PARAM_CROP_WIDTH

        protected static final java.lang.String PARAM_CROP_WIDTH
        cropWidth
        See Also:
        Constant Field Values
      • PARAM_CROP_HEIGHT

        protected static final java.lang.String PARAM_CROP_HEIGHT
        cropHeight
        See Also:
        Constant Field Values
      • PARAM_CROP_UNIFORM

        protected static final java.lang.String PARAM_CROP_UNIFORM
        cropUniform
        See Also:
        Constant Field Values
      • PARAM_CROP_UNITS

        protected static final java.lang.String PARAM_CROP_UNITS
        cropUnits
        See Also:
        Constant Field Values
    • Constructor Detail

      • CropFilter

        public CropFilter()
    • Method Detail

      • doFilter

        protected java.awt.image.RenderedImage doFilter​(java.awt.image.BufferedImage pImage,
                                                        javax.servlet.ServletRequest pRequest,
                                                        ImageServletResponse pResponse)
        Reads the image from the requested URL, scales it, crops it, and returns it in the Servlet stream. See above for details on parameters.
        Overrides:
        doFilter in class ScaleFilter
        Parameters:
        pImage - the image to filter
        pRequest - the servlet request
        pResponse - the servlet response
        Returns:
        the filtered image
      • getBounds

        protected java.awt.Rectangle getBounds​(int pX,
                                               int pY,
                                               int pWidth,
                                               int pHeight,
                                               int pUnits,
                                               boolean pUniform,
                                               java.awt.image.BufferedImage pImg)