Class JPEGFilter

  • All Implemented Interfaces:
    FormatFilter, SelfRegisterInputFormats

    public class JPEGFilter
    extends MediaFilter
    implements SelfRegisterInputFormats
    Filter image bitstreams, scaling the image to be within the bounds of thumbnail.maxwidth, thumbnail.maxheight, the size we want our thumbnail to be no bigger than. Creates only JPEGs.
    Author:
    Jason Sherman jsherman@usao.edu
    • Constructor Detail

      • JPEGFilter

        public JPEGFilter()
    • Method Detail

      • getFilteredName

        public String getFilteredName​(String oldFilename)
        Description copied from interface: FormatFilter
        Get a filename for a newly created filtered bitstream
        Specified by:
        getFilteredName in interface FormatFilter
        Parameters:
        oldFilename - name of source bitstream
        Returns:
        filename generated by the filter - for example, document.pdf becomes document.pdf.txt
      • getDestinationStream

        public InputStream getDestinationStream​(Item currentItem,
                                                InputStream source,
                                                boolean verbose)
                                         throws Exception
        Description copied from interface: FormatFilter
        Read the source stream and produce the filtered content.
        Specified by:
        getDestinationStream in interface FormatFilter
        Parameters:
        currentItem - item
        source - source input stream
        verbose - verbose mode
        Returns:
        InputStream the resulting input stream
        Throws:
        Exception - if error
      • getThumbDim

        public InputStream getThumbDim​(Item currentItem,
                                       BufferedImage buf,
                                       boolean verbose,
                                       float xmax,
                                       float ymax,
                                       boolean blurring,
                                       boolean hqscaling,
                                       int brandHeight,
                                       int brandFontPoint,
                                       String brandFont)
                                throws Exception
        Throws:
        Exception
      • getBlurredInstance

        public BufferedImage getBlurredInstance​(BufferedImage buf)
        Convenience method that returns a blurred instance of the provided BufferedImage.
        Parameters:
        buf - buffered image
        Returns:
        updated BufferedImage
      • getScaledInstance

        public BufferedImage getScaledInstance​(BufferedImage buf,
                                               int targetWidth,
                                               int targetHeight,
                                               Object hint,
                                               boolean higherQuality)
        Convenience method that returns a scaled instance of the provided BufferedImage.
        Parameters:
        buf - the original image to be scaled
        targetWidth - the desired width of the scaled instance, in pixels
        targetHeight - the desired height of the scaled instance, in pixels
        hint - one of the rendering hints that corresponds to RenderingHints.KEY_INTERPOLATION (e.g. RenderingHints.VALUE_INTERPOLATION_NEAREST_NEIGHBOR, RenderingHints.VALUE_INTERPOLATION_BILINEAR, RenderingHints.VALUE_INTERPOLATION_BICUBIC)
        higherQuality - if true, this method will use a multi-step scaling technique that provides higher quality than the usual one-step technique (only useful in downscaling cases, where targetWidth or targetHeight is smaller than the original dimensions, and generally only when the BILINEAR hint is specified)
        Returns:
        a scaled version of the original BufferedImage