Packages

o

web.utils

ImageTransforms

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.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. ImageTransforms
  2. AnyRef
  3. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. Protected

Type Members

  1. sealed trait Axis extends AnyRef
  2. sealed trait ImageFormat extends AnyRef
  3. sealed trait ThumbType extends AnyRef
  4. final case class TransformationError(message: String) extends AnyVal with Product with Serializable
  5. type TransformationResult = Either[TransformationError, File]

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##: Int
    Definition Classes
    AnyRef → Any
  3. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  4. 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

  5. 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

  6. 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

  7. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  8. 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

  9. 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

  10. 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

  11. 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

  12. def clone(): AnyRef
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.CloneNotSupportedException]) @HotSpotIntrinsicCandidate() @native()
  13. 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

  14. 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

  15. 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

  16. 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

  17. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  18. def equals(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef → Any
  19. 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

  20. def flip(image: ImmutableImage, axis: Axis): ImmutableImage

    Flips an image

    Flips an image

    image

    input

    axis

    Horizontal|Vertical

    returns

    flipped image

  21. 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

  22. final def getClass(): Class[_ <: AnyRef]
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  23. def hashCode(): Int
    Definition Classes
    AnyRef → Any
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  24. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  25. 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

  26. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  27. final def notify(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  28. final def notifyAll(): Unit
    Definition Classes
    AnyRef
    Annotations
    @HotSpotIntrinsicCandidate() @native()
  29. 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

  30. 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

  31. def scale(image: ImmutableImage, factor: Double): ImmutableImage

    Scales an image

    Scales an image

    image

    input

    factor

    as double

    returns

    scaled image

  32. 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

  33. final def synchronized[T0](arg0: => T0): T0
    Definition Classes
    AnyRef
  34. def toString(): String
    Definition Classes
    AnyRef → Any
  35. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  36. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException]) @native()
  37. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.InterruptedException])
  38. 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

  39. 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

  40. def zoom(image: ImmutableImage, factor: Double): ImmutableImage

    Close up

    Close up

    image

    input

    factor

    as double

    returns

    zoomed in image

  41. case object Desktop extends ThumbType with Product with Serializable
  42. case object Horizontal extends Axis with Product with Serializable
  43. case object Jpeg extends ImageFormat with Product with Serializable
  44. case object Mobile extends ThumbType with Product with Serializable
  45. case object Png extends ImageFormat with Product with Serializable
  46. case object Vertical extends Axis with Product with Serializable
  47. case object Webp extends ImageFormat with Product with Serializable

Deprecated Value Members

  1. def finalize(): Unit
    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws(classOf[java.lang.Throwable]) @Deprecated
    Deprecated

    (Since version 9)

Inherited from AnyRef

Inherited from Any

Ungrouped