Package digilib.image
Class ImageJobDescription
- java.lang.Object
-
- digilib.image.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 Summary
Fields Modifier and Type Field Description protected DigilibConfiguration
config
the global DigilibConfigurationprotected DocuDirCache
dirCache
protected DocuImage
docuImage
protected DocuDirectory
fileDir
protected String
filePath
protected ImageSize
hiresSize
protected Boolean
imageSendable
protected ImageSet
imageSet
protected Rectangle2D
imgArea
protected ImageSize
imgSize
protected ImageInput
input
protected static org.slf4j.Logger
logger
protected String
mimeType
protected ImageSize
minSourceSize
protected Rectangle2D
outerImgArea
protected Integer
paramDH
protected Integer
paramDW
protected float[]
paramRGBA
protected float[]
paramRGBM
protected Float
paramWH
protected Float
paramWW
protected Float
paramWX
protected Float
paramWY
protected boolean
preselectInputs
protected ParameterMap
request
the DigilibRequest for this jobprotected Double
scaleX
protected Double
scaleY
-
Constructor Summary
Constructors Constructor Description ImageJobDescription(DigilibConfiguration dlcfg, ParameterMap params)
Creates ImageJobDescription with a given ParameterMap.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description DocuImage.ColorOp
getColOp()
Return the color operation as a ColorOp.int
getDh()
Return the height of the destination image.DocuImage
getDocuImage()
int
getDw()
Return the width of the destination image.DocuDirectory
getFileDirectory()
Return the DocuDirectory for the input (file).String
getFilePath()
Return the file path name from the request.ImageSize
getHiresSize()
Return the size of the highest resolution image.ImageSet
getImageSet()
Return the ImageSet to load.ImageSize
getImgSize()
Return the size of the selected input image.ImageInput
getInput()
Returns the ImageInput to use.String
getInputMimeType()
Return the mime-type of the input.static ImageJobDescription
getInstance(DigilibRequest dlReq, DigilibConfiguration dlcfg)
Creates new ImageJobDescription from a DigilibRequest.static ImageJobDescription
getInstanceWithImageSet(DigilibRequest dlReq, ImageSet imgs, DigilibConfiguration dlcfg)
Creates new ImageJobDescription from a DigilibRequest and adding an ImageSet.ImageSize
getMinSourceSize()
Return the minimum size the source image should have for scaling.Rectangle2D
getOuterImgArea()
Return the maximum area of the source image that will be used.String
getOutputMimeType()
Return the mime-type of the output.static ImageJobDescription
getRawInstance(ParameterMap pm, DigilibConfiguration dlcfg)
Creates new ImageJobDescription with a given ParameterMap.ParameterMap
getRequest()
float[]
getRGBA()
Get the RGBA parameter set.float[]
getRGBM()
Get the RGBM parameter set.int
getScaleQual()
Return image quality as an integer.double
getScaleX()
Return the X scale factor.double
getScaleY()
Return the Y scale factor.Float
getWh()
Return the relative height of the image area.Float
getWw()
Return the relative width of the image area.Float
getWx()
Return the relative x-offset of the image area.Float
getWy()
Return the relative y-offset of the image area.boolean
isAbsoluteScale()
Scale according to fixed factor independent of destination size.boolean
isCropToFit()
Do not scale, just crop original resolution.boolean
isHiresOnly()
Only use the highest resolution image.boolean
isImageSendable()
Returns if the image can be sent without processing.boolean
isLoresOnly()
Prefer a prescaled lower resolution image.boolean
isScaleToFit()
Scale according to zoom area and destination size preserving aspect ratio.boolean
isSendAsFileRequested()
Returns if send-as-file has been requested?boolean
isSqueezeToFit()
Scale according to zoom area and destination size violating aspect ratio.boolean
isTransformRequired()
Returns if any transformation of the source image (image manipulation or format conversion) is required.boolean
isZoomRequested()
Returns if zoom has been requested.protected Rectangle2D
prepareAbsoluteScale()
Absolute scale factor: either original size, based on dpi, or absolute.protected Rectangle2D
prepareClipToFit()
Clip to fit: don't scale.void
prepareScaleParams()
Prepare image scaling factors and coordinates.protected Rectangle2D
prepareScaleToFit()
Scale to fit: scale factor based on destination size dw/dh and user area.protected Rectangle2D
prepareSqueezeToFit()
Squeeze to fit: scale factor based on destination size and user area.protected ImageInput
selectInput()
Returns the best ImageInput based on current request parameters.void
setDocuImage(DocuImage docuImage)
Set the current docuImage.void
setImageSet(ImageSet imageSet)
Set the current ImageSet.void
setImgSize(ImageSize size)
Set the image size.void
setInput(ImageInput input)
Set the current ImageInput.
-
-
-
Field Detail
-
config
protected DigilibConfiguration config
the global DigilibConfiguration
-
request
protected ParameterMap request
the DigilibRequest for this job
-
logger
protected static final org.slf4j.Logger logger
-
input
protected ImageInput input
-
imageSet
protected ImageSet imageSet
-
fileDir
protected DocuDirectory fileDir
-
docuImage
protected DocuImage docuImage
-
filePath
protected String filePath
-
minSourceSize
protected ImageSize minSourceSize
-
scaleX
protected Double scaleX
-
scaleY
protected Double scaleY
-
imgArea
protected Rectangle2D imgArea
-
outerImgArea
protected Rectangle2D outerImgArea
-
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
-
dirCache
protected DocuDirCache dirCache
-
hiresSize
protected ImageSize hiresSize
-
imgSize
protected ImageSize imgSize
-
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 DigilibConfigurationparams
- the ParameterMap
-
-
Method Detail
-
getInstance
public static ImageJobDescription getInstance(DigilibRequest dlReq, DigilibConfiguration dlcfg) throws IOException, ImageOpException
Creates new ImageJobDescription from a DigilibRequest.- Parameters:
dlReq
- the DigilibRequestdlcfg
- the DigilibConfiguration- Returns:
- the ImageJobDescription
- Throws:
ImageOpException
- on errorIOException
- on error
-
getInstanceWithImageSet
public static ImageJobDescription getInstanceWithImageSet(DigilibRequest dlReq, ImageSet imgs, DigilibConfiguration dlcfg) throws IOException, ImageOpException
Creates new ImageJobDescription from a DigilibRequest and adding an ImageSet.- Parameters:
dlReq
- the DigilibRequestimgs
- the ImageSetdlcfg
- the DigilibConfiguration- Returns:
- the ImageJobDescription
- Throws:
ImageOpException
- on errorIOException
- on error
-
getRawInstance
public static ImageJobDescription getRawInstance(ParameterMap pm, DigilibConfiguration dlcfg) throws IOException, ImageOpException
Creates new ImageJobDescription with a given ParameterMap. (Does not prepare scale parameters.)- Parameters:
pm
- the ParameterMapdlcfg
- the DigilibConfiguration- Returns:
- the ImageJobDescription
- Throws:
ImageOpException
- on errorIOException
- on error
-
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 errorImageOpException
- 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 errorImageOpException
- 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
-
selectInput
protected ImageInput selectInput() throws FileOpException, IOException
Returns the best ImageInput based on current request parameters.- Throws:
FileOpException
IOException
-
getFileDirectory
public DocuDirectory getFileDirectory() throws FileOpException
Return the DocuDirectory for the input (file).- Returns:
- the DocuDirectory
- Throws:
FileOpException
- on error
-
getImageSet
public ImageSet getImageSet() throws FileOpException
Return the ImageSet to load.- Returns:
- the ImageSet
- Throws:
FileOpException
- 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
-
getScaleX
public double getScaleX() throws IOException, ImageOpException
Return the X scale factor.- Returns:
- the factor
- Throws:
IOException
- on errorImageOpException
- on error
-
getScaleY
public double getScaleY() throws IOException, ImageOpException
Return the Y scale factor.- Returns:
- the factor
- Throws:
IOException
- on errorImageOpException
- on error
-
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 errorImageOpException
- 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
-
-