Class JPEGFilter

java.lang.Object
org.dspace.app.mediafilter.MediaFilter
org.dspace.app.mediafilter.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 Details

    • JPEGFilter

      public JPEGFilter()
  • Method Details

    • 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
    • getBundleName

      public String getBundleName()
      Specified by:
      getBundleName in interface FormatFilter
      Returns:
      String bundle name
    • getFormatString

      public String getFormatString()
      Specified by:
      getFormatString in interface FormatFilter
      Returns:
      String bitstreamformat
    • getDescription

      public String getDescription()
      Specified by:
      getDescription in interface FormatFilter
      Returns:
      String description
    • 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
    • getThumb

      public InputStream getThumb(Item currentItem, BufferedImage buf, boolean verbose) throws Exception
      Throws:
      Exception
    • 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
    • getInputMIMETypes

      public String[] getInputMIMETypes()
      Specified by:
      getInputMIMETypes in interface SelfRegisterInputFormats
    • getInputDescriptions

      public String[] getInputDescriptions()
      Specified by:
      getInputDescriptions in interface SelfRegisterInputFormats
    • getInputExtensions

      public String[] getInputExtensions()
      Specified by:
      getInputExtensions in interface SelfRegisterInputFormats
    • getNormalizedInstance

      public BufferedImage getNormalizedInstance(BufferedImage buf)
    • 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