Package digilib.image
Class ImageJobDescription
java.lang.Object
digilib.image.ImageJobDescription
A class for storing and calculating the set of parameters necessary for scaling images
with an ImageWorker.
- Author:
- cmielack, casties
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DigilibConfigurationthe global DigilibConfigurationprotected DocuDirCacheprotected DocuImageprotected DocuDirectoryprotected Stringprotected ImageSizeprotected Booleanprotected ImageSetprotected Rectangle2Dprotected ImageSizeprotected ImageInputprotected static final org.slf4j.Loggerprotected Stringprotected ImageSizeprotected Rectangle2Dprotected Integerprotected Integerprotected float[]protected float[]protected Floatprotected Floatprotected Floatprotected Floatprotected booleanprotected ParameterMapthe DigilibRequest for this jobprotected Doubleprotected Double -
Constructor Summary
ConstructorsConstructorDescriptionImageJobDescription(DigilibConfiguration dlcfg, ParameterMap params) Creates ImageJobDescription with a given ParameterMap. -
Method Summary
Modifier and TypeMethodDescriptiongetColOp()Return the color operation as a ColorOp.intgetDh()Return the height of the destination image.intgetDw()Return the width of the destination image.Return the DocuDirectory for the input (file).Return the file path name from the request.Return the size of the highest resolution image.Return the ImageSet to load.Return the size of the selected input image.getInput()Returns the ImageInput to use.Return the mime-type of the input.static ImageJobDescriptiongetInstance(DigilibRequest dlReq, DigilibConfiguration dlcfg) Creates new ImageJobDescription from a DigilibRequest.static ImageJobDescriptiongetInstanceWithImageSet(DigilibRequest dlReq, ImageSet imgs, DigilibConfiguration dlcfg) Creates new ImageJobDescription from a DigilibRequest and adding an ImageSet.Return the minimum size the source image should have for scaling.Return the maximum area of the source image that will be used.Return the mime-type of the output.static ImageJobDescriptiongetRawInstance(ParameterMap pm, DigilibConfiguration dlcfg) Creates new ImageJobDescription with a given ParameterMap.float[]getRGBA()Get the RGBA parameter set.float[]getRGBM()Get the RGBM parameter set.intReturn image quality as an integer.doubleReturn the X scale factor.doubleReturn the Y scale factor.getWh()Return the relative height of the image area.getWw()Return the relative width of the image area.getWx()Return the relative x-offset of the image area.getWy()Return the relative y-offset of the image area.booleanScale according to fixed factor independent of destination size.booleanDo not scale, just crop original resolution.booleanOnly use the highest resolution image.booleanReturns if the image can be sent without processing.booleanPrefer a prescaled lower resolution image.booleanScale according to zoom area and destination size preserving aspect ratio.booleanReturns if send-as-file has been requested?booleanScale according to zoom area and destination size violating aspect ratio.booleanReturns if any transformation of the source image (image manipulation or format conversion) is required.booleanReturns if zoom has been requested.protected Rectangle2DAbsolute scale factor: either original size, based on dpi, or absolute.protected Rectangle2DClip to fit: don't scale.voidPrepare image scaling factors and coordinates.protected Rectangle2DScale to fit: scale factor based on destination size dw/dh and user area.protected Rectangle2DSqueeze to fit: scale factor based on destination size and user area.protected ImageInputReturns the best ImageInput based on current request parameters.voidsetDocuImage(DocuImage docuImage) Set the current docuImage.voidsetImageSet(ImageSet imageSet) Set the current ImageSet.voidsetImgSize(ImageSize size) Set the image size.voidsetInput(ImageInput input) Set the current ImageInput.
-
Field Details
-
config
the global DigilibConfiguration -
request
the DigilibRequest for this job -
logger
protected static final org.slf4j.Logger logger -
input
-
imageSet
-
fileDir
-
docuImage
-
filePath
-
minSourceSize
-
scaleX
-
scaleY
-
imgArea
-
outerImgArea
-
imageSendable
-
mimeType
-
paramDW
-
paramDH
-
paramWX
-
paramWY
-
paramWW
-
paramWH
-
paramRGBM
protected float[] paramRGBM -
paramRGBA
protected float[] paramRGBA -
dirCache
-
hiresSize
-
imgSize
-
preselectInputs
protected boolean preselectInputs
-
-
Constructor Details
-
ImageJobDescription
Creates ImageJobDescription with a given ParameterMap. (Does not prepare scale parameters.)- Parameters:
dlcfg- the DigilibConfigurationparams- the ParameterMap
-
-
Method Details
-
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
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
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
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
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
Clip to fit: don't scale. Sets ScaleX and ScaleY to 1.0.- Returns:
- the Rectangle2D
- Throws:
IOException- on error
-
getInputMimeType
Return the mime-type of the input.- Returns:
- the mimetype
- Throws:
IOException- on error
-
getOutputMimeType
Return the mime-type of the output.- Returns:
- the mimetype
-
setInput
Set the current ImageInput.- Parameters:
input- the input to set
-
getInput
Returns the ImageInput to use. Note: uses getMinSourceSize().- Returns:
- the ImageInput
- Throws:
IOException- on error
-
selectInput
Returns the best ImageInput based on current request parameters.- Throws:
FileOpExceptionIOException
-
getFileDirectory
Return the DocuDirectory for the input (file).- Returns:
- the DocuDirectory
- Throws:
FileOpException- on error
-
getImageSet
Return the ImageSet to load.- Returns:
- the ImageSet
- Throws:
FileOpException- on error
-
setImageSet
Set the current ImageSet.- Parameters:
imageSet- the ImageSet
-
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
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
Return the size of the highest resolution image.- Returns:
- the ImageSize
- Throws:
IOException- on error
-
getImgSize
Return the size of the selected input image. Note: may use getMinSourceSize().- Returns:
- the ImageSize
- Throws:
IOException- on error
-
setImgSize
Set the image size.- Parameters:
size- the ImageSize
-
getScaleX
Return the X scale factor.- Returns:
- the factor
- Throws:
IOException- on errorImageOpException- on error
-
getScaleY
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
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
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
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
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
Return the color operation as a ColorOp.- Returns:
- the ColorOp
-
getOuterImgArea
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
Returns if zoom has been requested.- Returns:
- Throws:
IOException
-
isImageSendable
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
Returns if any transformation of the source image (image manipulation or format conversion) is required.- Returns:
- is transform required
- Throws:
IOException- on error
-
getRequest
- Returns:
- the DigilibRequest
-
getDocuImage
- Returns:
- the docuImage
-
setDocuImage
Set the current docuImage.- Parameters:
docuImage- the docuImage to set
-