Class Encode
java.lang.Object
is.galia.operation.Encode
- All Implemented Interfaces:
Operation
Encapsulates an image encoding operation.
Typically appears at the very end of an OperationList
.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
Any key supplied tosetOption(String, Object)
must start with this string. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
freeze()
Makes the instance unmodifiable.int
getXMP()
boolean
Simpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList)
.boolean
hasEffect
(Size fullSize, OperationList opList) Context-aware counterpart toOperation.hasEffect()
.void
removeOption
(String key) void
setBackgroundColor
(Color color) void
void
setMaxComponentSize
(int depth) void
setNativeMetadata
(NativeMetadata metadata) void
Some encoders may support their own custom encoding options.void
toMap
(Size fullSize, ScaleConstraint scaleConstraint) Returns a map in the following format:toString()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface is.galia.operation.Operation
getResultingSize, validate
-
Field Details
-
OPTION_PREFIX
Any key supplied tosetOption(String, Object)
must start with this string.- See Also:
-
-
Constructor Details
-
Encode
-
-
Method Details
-
freeze
public void freeze()Description copied from interface:Operation
Makes the instance unmodifiable. When frozen, mutation methods should throw anIllegalStateException
and getters should return immutable values, if possible. (But they should do that anyway.) -
getBackgroundColor
- Returns:
- Color with which to fill the empty portions of the image when
getFormat()
returns a format that does not support transparency and when either rotating by a non-90-degree multiple, or when flattening an image with alpha. May benull
.
-
getFormat
-
getMaxComponentSize
public int getMaxComponentSize()- Returns:
- Maximum sample size to encode. May be
Integer.MAX_VALUE
indicating no max.
-
getNativeMetadata
- Returns:
- Native metadata.
-
getOptions
- Returns:
- Unmodifiable options.
- See Also:
-
getXMP
-
hasEffect
public boolean hasEffect()Description copied from interface:Operation
Simpler but less-accurate counterpart ofOperation.hasEffect(Size, OperationList)
. -
hasEffect
Description copied from interface:Operation
Context-aware counterpart toOperation.hasEffect()
. For example, a scale operation specifying a scale to 300×200, when the given operation list contains a crop of 300×200, would returnfalse
. -
removeOption
- Throws:
IllegalStateException
- if the instance is frozen.
-
setBackgroundColor
- Parameters:
color
- Background color.- Throws:
IllegalStateException
- if the instance is frozen.
-
setFormat
- Parameters:
format
- Format to set.- Throws:
IllegalStateException
- if the instance is frozen.
-
setMaxComponentSize
public void setMaxComponentSize(int depth) - Parameters:
depth
- Maximum sample size to encode. Supply0
to indicate no max.- Throws:
IllegalStateException
- if the instance is frozen.
-
setNativeMetadata
- Parameters:
metadata
- Native metadata.- Throws:
IllegalStateException
- if the instance is frozen.
-
setOption
Some encoders may support their own custom encoding options. Rather than forcing them to draw this information directly from the application configuration, which would make it invisible in the operation pipeline (and therefore not considered in e.g. variant image cache keys), these options can be supplied here, where they will affect the output of
toString()
andtoMap(is.galia.image.Size, is.galia.image.ScaleConstraint)
.- Parameters:
key
- Option key, which must start withOPTION_PREFIX
. No other constraints are imposed, but as keys are drawn from the application configuration, they should align with that syntax.value
- Option value.- Throws:
IllegalArgumentException
- if the key does not conform to the required syntax.IllegalStateException
- if the instance is frozen.- See Also:
-
setXMP
- Parameters:
xmp
- Embeddable XMP metadata.rdf:RDF
is the enclosing tag.- Throws:
IllegalStateException
- if the instance is frozen.
-
toMap
Returns a map in the following format:
{ class: "Encode" background_color: Hexadecimal string format: Media type string max_sample_size: Integer native_metadata: See
NativeMetadata.toMap()
xmp: String options: { key1: value key2: value } } -
toString
-