Package adams.data.image.transformer
Class Resize
-
- All Implemented Interfaces:
CleanUpHandler
,Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,QuickInfoSupporter
,SizeOfHandler
,ImageTransformer<BufferedImageContainer>
,FlowContextHandler
,Serializable
,Comparable
public class Resize extends AbstractBufferedImageTransformer
Resizes the image to predefined width and height.
For more information on the scaling types, see:
https://docs.oracle.com/en/java/javase/11/docs/api/java.desktop/java/awt/Image.html
-logging-level <OFF|SEVERE|WARNING|INFO|CONFIG|FINE|FINER|FINEST> (property: loggingLevel) The logging level for outputting errors and debugging output. default: WARNING
-width <double> (property: width) The width to resize the image to; use -1 to use original width; use (0-1 ) for percentage. default: -1.0 minimum: -1.0
-height <double> (property: height) The height to resize the image to; use -1 to use original height; use (0 -1) for percentage. default: -1.0 minimum: -1.0
-scaling-type <DEFAULT|FAST|SMOOTH|REPLICATE|AREA_AVERAGING> (property: scalingType) The type of scaling to perform. default: DEFAULT
-force-percentage <boolean> (property: forcePercentage) Whether to always interpret width/height as percentage (eg when upscaling the image). default: false
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
Resize.ScalingType
Type of scaling to perform.
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_ForcePercentage
whether to force percentage (eg for scaling larger).protected double
m_Height
the new height.protected Resize.ScalingType
m_ScalingType
the type of interpolation to perform.protected double
m_Width
the new width.-
Fields inherited from class adams.data.image.AbstractImageTransformer
m_FlowContext
-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Constructor Description Resize()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
defineOptions()
Adds options to the internal list of options.protected BufferedImageContainer[]
doTransform(BufferedImageContainer img)
Performs no transformation at all, just returns the input.String
forcePercentageTipText()
Returns the tip text for this property.boolean
getForcePercentage()
Returns whether to always interpret the width/height as percentage (eg when upscaling the image).double
getHeight()
Returns the height to resize to.Resize.ScalingType
getScalingType()
Returns the type of interpolation in use.double
getWidth()
Returns the width to resize to.String
globalInfo()
Returns a string describing the object.String
heightTipText()
Returns the tip text for this property.String
scalingTypeTipText()
Returns the tip text for this property.void
setForcePercentage(boolean value)
Sets whether to always interpret the width/height as percentage (eg when upscaling the image).void
setHeight(double value)
Sets the height to resize to.void
setScalingType(Resize.ScalingType value)
Sets the type of interpolation to use.void
setWidth(double value)
Sets the width to resize to.String
widthTipText()
Returns the tip text for this property.-
Methods inherited from class adams.data.image.transformer.AbstractBufferedImageTransformer
forCommandLine, forName, getTransformations
-
Methods inherited from class adams.data.image.AbstractImageTransformer
checkImage, cleanUp, compareTo, destroy, equals, getFlowContext, getQuickInfo, initialize, setFlowContext, shallowCopy, shallowCopy, transform
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, reset, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_Width
protected double m_Width
the new width.
-
m_Height
protected double m_Height
the new height.
-
m_ScalingType
protected Resize.ScalingType m_ScalingType
the type of interpolation to perform.
-
m_ForcePercentage
protected boolean m_ForcePercentage
whether to force percentage (eg for scaling larger).
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
setWidth
public void setWidth(double value)
Sets the width to resize to.- Parameters:
value
- the width, -1 uses original width
-
getWidth
public double getWidth()
Returns the width to resize to.- Returns:
- the width, -1 if original width is used
-
widthTipText
public String widthTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setHeight
public void setHeight(double value)
Sets the height to resize to.- Parameters:
value
- the height, -1 uses original height
-
getHeight
public double getHeight()
Returns the height to resize to.- Returns:
- the height, -1 if original height is used
-
heightTipText
public String heightTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setScalingType
public void setScalingType(Resize.ScalingType value)
Sets the type of interpolation to use.- Parameters:
value
- the type
-
getScalingType
public Resize.ScalingType getScalingType()
Returns the type of interpolation in use.- Returns:
- the type
-
scalingTypeTipText
public String scalingTypeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setForcePercentage
public void setForcePercentage(boolean value)
Sets whether to always interpret the width/height as percentage (eg when upscaling the image).- Parameters:
value
- true if to force
-
getForcePercentage
public boolean getForcePercentage()
Returns whether to always interpret the width/height as percentage (eg when upscaling the image).- Returns:
- true if to force
-
forcePercentageTipText
public String forcePercentageTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
doTransform
protected BufferedImageContainer[] doTransform(BufferedImageContainer img)
Performs no transformation at all, just returns the input.- Specified by:
doTransform
in classAbstractImageTransformer<BufferedImageContainer>
- Parameters:
img
- the image to process (can be modified, since it is a copy)- Returns:
- the copy of the image
-
-