Package dev.aherscu.qa.testing.utils
Class ImageUtils.Pipeline
- java.lang.Object
-
- dev.aherscu.qa.testing.utils.ImageUtils.Pipeline
-
- Enclosing class:
- ImageUtils
public static class ImageUtils.Pipeline extends Object
Image transformation pipeline. Callfrom(InputStream)
orfrom(BufferedImage)
to start the pipeline. Callinto(Supplier, String)
to end the pipeline.
-
-
Field Summary
Fields Modifier and Type Field Description BufferedImage
image
The encapsulated image in this pipeline.
-
Constructor Summary
Constructors Constructor Description Pipeline(BufferedImage image)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description <D> D
diff(BufferedImage other, Function<org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>,D> differentiator)
Difference between this image and other image.<D> D
diff(BufferedImage other, Function<org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>,D> differentiator, Function<org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>,org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>> adapter)
Difference between this image and other image.static ImageUtils.Pipeline
from(BufferedImage image)
Starts an image processing pipeline.static ImageUtils.Pipeline
from(InputStream input)
Starts an image processing pipeline.<OUTPUT extends OutputStream>
OUTPUTinto(Supplier<OUTPUT> outputSupplier, String format)
Ends the image processing pipeline.<OUTPUT extends OutputStream>
OUTPUTinto(OUTPUT output, String format)
Ends the image processing pipeline.ImageUtils.Pipeline
map(UnaryOperator<ImageUtils.Pipeline> pipeline)
Applies a specified pipeline.ImageUtils.Pipeline
reduce(IndexColorModel indexColorModel)
Reduces the color palette per specified model.ImageUtils.Pipeline
scale(double widthScale, double heightScale)
Scales by specified factors.ImageUtils.Pipeline
scale(float widthScale, float heightScale, Map<RenderingHints.Key,Object> hints)
Scales by specified factors and hints.
-
-
-
Field Detail
-
image
public final BufferedImage image
The encapsulated image in this pipeline.
-
-
Constructor Detail
-
Pipeline
public Pipeline(BufferedImage image)
-
-
Method Detail
-
from
public static ImageUtils.Pipeline from(BufferedImage image)
Starts an image processing pipeline.- Parameters:
image
- the image to process- Returns:
- a processing pipeline
-
from
public static ImageUtils.Pipeline from(InputStream input)
Starts an image processing pipeline.- Parameters:
input
- input stream providing the image to process- Returns:
- a processing pipeline
-
into
public <OUTPUT extends OutputStream> OUTPUT into(OUTPUT output, String format)
Ends the image processing pipeline.- Type Parameters:
OUTPUT
- type of output stream- Parameters:
output
- the output stream to serialize intoformat
- informal image format label- Returns:
- the filled output stream; useful with in-memory streams (e.g.
ByteArrayOutputStream
-
into
public <OUTPUT extends OutputStream> OUTPUT into(Supplier<OUTPUT> outputSupplier, String format)
Ends the image processing pipeline.- Type Parameters:
OUTPUT
- type of output stream- Parameters:
outputSupplier
- the output stream to serialize into; will be closed automaticallyformat
- informal image format label- Returns:
- the filled output stream; useful with in-memory streams (e.g.
ByteArrayOutputStream
-
map
public ImageUtils.Pipeline map(UnaryOperator<ImageUtils.Pipeline> pipeline)
Applies a specified pipeline. Allows using predefined pipelines.- Parameters:
pipeline
- a specified pipeline- Returns:
- this pipeline
-
reduce
public ImageUtils.Pipeline reduce(IndexColorModel indexColorModel)
Reduces the color palette per specified model.- Parameters:
indexColorModel
- the color model to apply- Returns:
- this pipeline
-
scale
public ImageUtils.Pipeline scale(double widthScale, double heightScale)
Scales by specified factors.Good quality when scaling down.
- Parameters:
widthScale
- the width scale factorheightScale
- the height scale factor- Returns:
- this pipeline
-
scale
public ImageUtils.Pipeline scale(float widthScale, float heightScale, Map<RenderingHints.Key,Object> hints)
Scales by specified factors and hints.Good quality when scaling down.
- Parameters:
widthScale
- the width scale factorheightScale
- the height scale factorhints
- rendering hints- Returns:
- this pipeline
- See Also:
ImageUtils.DEFAULT_RENDERING_HINTS
-
diff
public <D> D diff(BufferedImage other, Function<org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>,D> differentiator, Function<org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>,org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>> adapter)
Difference between this image and other image.- Type Parameters:
D
- type of difference- Parameters:
other
- image to find difference fromdifferentiator
- a differentiating methodadapter
- an adaptation method, e.g.ImageUtils.adapt(Pair)
- Returns:
- the difference
-
diff
public <D> D diff(BufferedImage other, Function<org.apache.commons.lang3.tuple.Pair<BufferedImage,BufferedImage>,D> differentiator)
Difference between this image and other image.- Type Parameters:
D
- type of difference- Parameters:
other
- image to find difference fromdifferentiator
- a differentiating method- Returns:
- the difference
-
-