Package digilib.image

Class ImageJobDescription


  • public class ImageJobDescription
    extends Object
    A class for storing and calculating the set of parameters necessary for scaling images with an ImageWorker.
    Author:
    cmielack, casties
    • Field Detail

      • request

        protected ParameterMap request
        the DigilibRequest for this job
      • logger

        protected static final org.slf4j.Logger logger
      • filePath

        protected String filePath
      • minSourceSize

        protected ImageSize minSourceSize
      • scaleX

        protected Double scaleX
      • scaleY

        protected Double scaleY
      • imageSendable

        protected Boolean imageSendable
      • mimeType

        protected String mimeType
      • paramDW

        protected Integer paramDW
      • paramDH

        protected Integer paramDH
      • paramWX

        protected Float paramWX
      • paramWY

        protected Float paramWY
      • paramWW

        protected Float paramWW
      • paramWH

        protected Float paramWH
      • paramRGBM

        protected float[] paramRGBM
      • paramRGBA

        protected float[] paramRGBA
      • preselectInputs

        protected boolean preselectInputs
    • Constructor Detail

      • ImageJobDescription

        public ImageJobDescription​(DigilibConfiguration dlcfg,
                                   ParameterMap params)
        Creates ImageJobDescription with a given ParameterMap. (Does not prepare scale parameters.)
        Parameters:
        dlcfg - the DigilibConfiguration
        params - the ParameterMap
    • Method Detail

      • prepareScaleParams

        public void prepareScaleParams()
                                throws IOException,
                                       ImageOpException
        Prepare image scaling factors and coordinates. Should be called by getInstance(). Uses image size and user parameters. Sets scaleX, scaleY, imgArea.
        Throws:
        IOException - on error
        ImageOpException - on error
      • prepareScaleToFit

        protected Rectangle2D prepareScaleToFit()
                                         throws IOException
        Scale to fit: scale factor based on destination size dw/dh and user area. Uses a uniform scale factor for x and y. Sets ScaleX and ScaleY.
        Returns:
        the Rectangle2D
        Throws:
        IOException - on error
      • prepareSqueezeToFit

        protected Rectangle2D prepareSqueezeToFit()
                                           throws IOException
        Squeeze to fit: scale factor based on destination size and user area. Uses separate scale factors for x and y to fill destination size changing aspect ratio. Sets ScaleX and ScaleY.
        Returns:
        the Rectangle2D
        Throws:
        IOException - on error
      • prepareAbsoluteScale

        protected Rectangle2D prepareAbsoluteScale()
                                            throws IOException,
                                                   ImageOpException
        Absolute scale factor: either original size, based on dpi, or absolute. Uses a uniform scale factor for x and y. Sets ScaleX and ScaleY.
        Returns:
        the Rectangle2D
        Throws:
        IOException - on error
        ImageOpException - on error
      • prepareClipToFit

        protected Rectangle2D prepareClipToFit()
                                        throws IOException
        Clip to fit: don't scale. Sets ScaleX and ScaleY to 1.0.
        Returns:
        the Rectangle2D
        Throws:
        IOException - on error
      • getInputMimeType

        public String getInputMimeType()
                                throws IOException
        Return the mime-type of the input.
        Returns:
        the mimetype
        Throws:
        IOException - on error
      • getOutputMimeType

        public String getOutputMimeType()
        Return the mime-type of the output.
        Returns:
        the mimetype
      • setInput

        public void setInput​(ImageInput input)
        Set the current ImageInput.
        Parameters:
        input - the input to set
      • getInput

        public ImageInput getInput()
                            throws IOException
        Returns the ImageInput to use. Note: uses getMinSourceSize().
        Returns:
        the ImageInput
        Throws:
        IOException - on error
      • setImageSet

        public void setImageSet​(ImageSet imageSet)
        Set the current ImageSet.
        Parameters:
        imageSet - the ImageSet
      • getFilePath

        public String getFilePath()
        Return the file path name from the request.
        Returns:
        the filepath
      • isHiresOnly

        public boolean isHiresOnly()
        Only use the highest resolution image.
        Returns:
        is Hires Only
      • isLoresOnly

        public boolean isLoresOnly()
        Prefer a prescaled lower resolution image.
        Returns:
        is lores only
      • isScaleToFit

        public boolean isScaleToFit()
        Scale according to zoom area and destination size preserving aspect ratio.
        Returns:
        is scale to fit
      • isCropToFit

        public boolean isCropToFit()
        Do not scale, just crop original resolution.
        Returns:
        is crop to fit
      • isSqueezeToFit

        public boolean isSqueezeToFit()
        Scale according to zoom area and destination size violating aspect ratio.
        Returns:
        is squeeze to fit
      • isAbsoluteScale

        public boolean isAbsoluteScale()
        Scale according to fixed factor independent of destination size.
        Returns:
        is absolute scale
      • getMinSourceSize

        public ImageSize getMinSourceSize()
                                   throws IOException
        Return the minimum size the source image should have for scaling. Note: this function is called by getInput(). It must not assume a selected input image!
        Returns:
        the ImageSize
        Throws:
        IOException - on error
      • getHiresSize

        public ImageSize getHiresSize()
                               throws IOException
        Return the size of the highest resolution image.
        Returns:
        the ImageSize
        Throws:
        IOException - on error
      • getImgSize

        public ImageSize getImgSize()
                             throws IOException
        Return the size of the selected input image. Note: may use getMinSourceSize().
        Returns:
        the ImageSize
        Throws:
        IOException - on error
      • setImgSize

        public void setImgSize​(ImageSize size)
        Set the image size.
        Parameters:
        size - the ImageSize
      • getDw

        public int getDw()
        Return the width of the destination image. Uses dw parameter.
        Returns:
        the dw
      • getDh

        public int getDh()
        Return the height of the destination image. Uses dh parameter.
        Returns:
        the dh
      • getWw

        public Float getWw()
                    throws IOException
        Return the relative width of the image area. Uses ww parameter. Converts ww in pixels to relative.
        Returns:
        the ww
        Throws:
        IOException - on error
      • getWh

        public Float getWh()
                    throws IOException
        Return the relative height of the image area. Uses wh parameter. Converts wh in pixels to relative.
        Returns:
        the wh
        Throws:
        IOException - on error
      • getWx

        public Float getWx()
                    throws IOException
        Return the relative x-offset of the image area. Uses wx parameter. Converts wx in pixels to relative.
        Returns:
        the wx
        Throws:
        IOException - on error
      • getWy

        public Float getWy()
                    throws IOException
        Return the relative y-offset of the image area. Uses wy parameter. Converts wy in pixels to relative.
        Returns:
        the wy
        Throws:
        IOException - on error
      • getScaleQual

        public int getScaleQual()
        Return image quality as an integer.
        Returns:
        the scale quality
      • getColOp

        public DocuImage.ColorOp getColOp()
        Return the color operation as a ColorOp.
        Returns:
        the ColorOp
      • getOuterImgArea

        public Rectangle2D getOuterImgArea()
                                    throws IOException,
                                           ImageOpException
        Return the maximum area of the source image that will be used. This was meant to include extra pixels outside the imgArea when rotating by oblique angles but is not yet implemented. Currently returns imgArea.
        Returns:
        the Rectangle2D
        Throws:
        IOException - on error
        ImageOpException - on error
      • getRGBM

        public float[] getRGBM()
        Get the RGBM parameter set.
        Returns:
        the rgbm
      • getRGBA

        public float[] getRGBA()
        Get the RGBA parameter set.
        Returns:
        the rgba
      • isSendAsFileRequested

        public boolean isSendAsFileRequested()
        Returns if send-as-file has been requested?
        Returns:
        is send as file
      • isZoomRequested

        public boolean isZoomRequested()
                                throws IOException
        Returns if zoom has been requested.
        Returns:
        Throws:
        IOException
      • isImageSendable

        public boolean isImageSendable()
                                throws IOException
        Returns if the image can be sent without processing. Takes image type and additional image operations into account. Does not check requested size transformation.
        Returns:
        is image sendable
        Throws:
        IOException - on error
      • isTransformRequired

        public boolean isTransformRequired()
                                    throws IOException
        Returns if any transformation of the source image (image manipulation or format conversion) is required.
        Returns:
        is transform required
        Throws:
        IOException - on error
      • getRequest

        public ParameterMap getRequest()
        Returns:
        the DigilibRequest
      • getDocuImage

        public DocuImage getDocuImage()
        Returns:
        the docuImage
      • setDocuImage

        public void setDocuImage​(DocuImage docuImage)
        Set the current docuImage.
        Parameters:
        docuImage - the docuImage to set