object ImageTransforms
Functional utilities for image processing with safe IO using Either.
All operations that involve reading or writing files return TransformationResult, where Left(errorMessage) indicates failure and Right(file) indicates success.
- Alphabetic
- By Inheritance
- ImageTransforms
- AnyRef
- Any
- Hide All
- Show All
- Public
- Protected
Type Members
- sealed trait Axis extends AnyRef
- sealed trait ImageFormat extends AnyRef
- sealed trait ThumbType extends AnyRef
- final case class TransformationError(message: String) extends AnyVal with Product with Serializable
- type TransformationResult = Either[TransformationError, File]
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- final def ##: Int
- Definition Classes
- AnyRef → Any
- final def ==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
- def addBorder(inputFiles: Seq[File], outputDir: File, color: RGBColor, thickness: Int): Seq[TransformationResult]
Takes a list of Files and adds a border to them
Takes a list of Files and adds a border to them
- inputFiles
input
- outputDir
output path
- color
RGBColor
- thickness
factor as double
- returns
Either Seq of error messages or the output files
- def addBorder(image: File, outputDir: File, rgb: RGBColor, thickness: Int): TransformationResult
Adds a border
Adds a border
- image
input
- outputDir
output path
- rgb
color
- thickness
border thickness
- returns
Either an error message or the output File
- def addBorder(image: ImmutableImage, rgb: RGBColor, thickness: Int): ImmutableImage
Adds a border
Adds a border
- image
input
- rgb
color
- thickness
border thickness
- returns
border-padded image
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def autoCrop(inputFile: File, outputFile: File, bgColor: Option[Color]): TransformationResult
Automatically crops an image, optionally using a color as the background reference, safely.
Automatically crops an image, optionally using a color as the background reference, safely.
- inputFile
the input file to crop
- outputFile
the destination file
- bgColor
optional Color used as background
- returns
TransformationResult
- def autoCrop(image: ImmutableImage, bgColor: Option[Color] = None): ImmutableImage
Automatically crops an image, optionally using a color as the background reference, safely.
Automatically crops an image, optionally using a color as the background reference, safely.
- image
immutable image
- bgColor
optional Color used as background
- returns
TransformationResult
- def bound(image: File, outputDir: File, dim: Dimension): TransformationResult
If the source image is larger, it will be scaled down, maintaining aspect ratio.
If the source image is larger, it will be scaled down, maintaining aspect ratio. If the source image is smaller, it will be returned unmodified.
- image
input
- outputDir
output path
- dim
Dimension(wxh)
- returns
Either an error message or the output File
- def bound(image: ImmutableImage, dims: Dimension): ImmutableImage
If the source image is larger, it will be scaled down, maintaining aspect ratio.
If the source image is larger, it will be scaled down, maintaining aspect ratio. If the source image is smaller, it will be returned unmodified.
- image
input
- dims
Dimension(wxh)
- returns
bounded image
- def clone(): AnyRef
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
- def convertTo(inputFiles: Seq[File], outputDir: File, format: ImageFormat): Seq[TransformationResult]
Convert a list of images to WebP safely.
Convert a list of images to WebP safely.
- inputFiles
list of image files
- outputDir
folder to save converted images
- format
image writer
- returns
sequence of TransformationResult
- def convertTo(inputFile: File, outputDir: File, format: ImageFormat): TransformationResult
Convert a single image to WebP safely.
Convert a single image to WebP safely.
- inputFile
the image file to convert
- outputDir
folder to save the converted image
- format
image writer
- returns
Either an error message or the output File
- def createThumbnail(inputFiles: Seq[File], outputDir: File, thumbType: ThumbType): Seq[TransformationResult]
Generate thumbnails for a list of images safely.
Generate thumbnails for a list of images safely.
- inputFiles
list of image files
- outputDir
folder to save thumbnails
- thumbType
"desktop" or "mobile"
- returns
sequence of TransformationResult
- def createThumbnail(inputFile: File, outputDir: File, thumbType: ThumbType): TransformationResult
Generate a thumbnail for a single image safely.
Generate a thumbnail for a single image safely.
- inputFile
the image file
- outputDir
folder to save thumbnail
- thumbType
"desktop" or "mobile"
- returns
Either an error message or the thumbnail File
- final def eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- def equals(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef → Any
- def flip(image: File, outputDir: File, axis: Axis): TransformationResult
Flips an image
Flips an image
- image
input
- outputDir
output path
- axis
Horizontal|Vertical
- returns
Either an error message or the output File
- def flip(image: ImmutableImage, axis: Axis): ImmutableImage
Flips an image
Flips an image
- image
input
- axis
Horizontal|Vertical
- returns
flipped image
- def generatePlaceholders(number: Int, width: Int, height: Int, fillColor: Option[Color] = None, applyBlur: Boolean = true, outputDir: File): Seq[TransformationResult]
Generates a series of placeholder images safely.
Generates a series of placeholder images safely.
- number
the number of placeholder images to generate
- width
width of each image
- height
height of each image
- fillColor
optional Color to fill the image; if None, transparent
- applyBlur
whether to apply a blur effect
- outputDir
folder to write placeholder images
- returns
sequence of TransformationResult
- final def getClass(): Class[_ <: AnyRef]
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def listImages(inputDir: File): Seq[File]
List all supported image files in a folder.
List all supported image files in a folder.
- inputDir
the folder to scan for image files
- returns
sequence of valid image files
- final def ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
- final def notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- final def notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @HotSpotIntrinsicCandidate() @native()
- def scale(inputFiles: Seq[File], outputDir: File, factor: Double): Seq[TransformationResult]
Takes a list of Files and scales them
Takes a list of Files and scales them
- inputFiles
input
- outputDir
output path
- factor
factor as double
- returns
Either Seq of error messages or the output files
- def scale(image: File, outputDir: File, factor: Double): TransformationResult
Scales an image
Scales an image
- image
input
- factor
as double
- returns
Either an error message or the output File
- def scale(image: ImmutableImage, factor: Double): ImmutableImage
Scales an image
Scales an image
- image
input
- factor
as double
- returns
scaled image
- def stripMetadata(inputFile: File, outputFile: File): TransformationResult
Removes all metadata from an image and saves it as a clean PNG safely.
Removes all metadata from an image and saves it as a clean PNG safely.
- inputFile
the image file to process
- outputFile
destination file for stripped image
- returns
TransformationResult
- final def synchronized[T0](arg0: => T0): T0
- Definition Classes
- AnyRef
- def toString(): String
- Definition Classes
- AnyRef → Any
- final def wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- final def wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException]) @native()
- final def wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.InterruptedException])
- def zoom(inputFiles: Seq[File], outputDir: File, factor: Double): Seq[TransformationResult]
Takes a list of Files and zooms in them
Takes a list of Files and zooms in them
- inputFiles
input
- outputDir
output path
- factor
factor as double
- returns
Either Seq of error messages or the output files
- def zoom(image: File, outputDir: File, factor: Double): TransformationResult
Close up
Close up
- image
input
- factor
as double
- returns
Either an error message or the output File
- def zoom(image: ImmutableImage, factor: Double): ImmutableImage
Close up
Close up
- image
input
- factor
as double
- returns
zoomed in image
- case object Desktop extends ThumbType with Product with Serializable
- case object Horizontal extends Axis with Product with Serializable
- case object Jpeg extends ImageFormat with Product with Serializable
- case object Mobile extends ThumbType with Product with Serializable
- case object Png extends ImageFormat with Product with Serializable
- case object Vertical extends Axis with Product with Serializable
- case object Webp extends ImageFormat with Product with Serializable
Deprecated Value Members
- def finalize(): Unit
- Attributes
- protected[lang]
- Definition Classes
- AnyRef
- Annotations
- @throws(classOf[java.lang.Throwable]) @Deprecated
- Deprecated
(Since version 9)