Skip to content
Sign in

image-resize

v0.3.1

Downscale JPEG, PNG and WebP images to fit or fill a box (EXIF-aware, never enlarges; JPEG, PNG or lossy WebP out)

license: Apache-2.0imagejpegmediapngresizewebp

Install

bash
iii call compose::add worker=image-resize@0.3.1

Run in your project with the iii engine running. Exact versions are immutable and digest-pinned.

Functions3

image-resize::on-config-change

Function

Internal: re-read the image-resize configuration after a change.

Request
  • idstring

    Configuration id that changed.

Response
  • okbooleanrequired

image-resize::ui-content

Function

Serve the image-resize worker's injected console UI assets (the target of its ade::ui::asset observers; the console calls it through each asset's observer with {path}).

Request
  • pathstringrequired

    The asset path from the observer's args (e.g. `state/page.js`).

Response
  • contentstringrequired

    The asset source, verbatim.

  • content_typestringrequired

    MIME type the console should serve the asset with.

image_resize::resize

Function

Downscale a JPEG, PNG or WebP image read from input_channel to fit or fill a box, never enlarging it, and write JPEG, PNG or lossy WebP bytes to output_channel.

Request
  • input_channelobjectrequired

    A stream the function reads: the ref of the read end of an engine pipe ({channel_id, access_key, direction: "read"}). The SDK opens it on first read.

    • access_keystringrequired
    • channel_idstringrequired
    • directionstringrequired
  • metadataany of
    any of (2)
    Variant 1
    • formatunknown

      Deprecated and ignored; removed in the next version. The input format is detected.

    • heightunknown

      Deprecated and ignored; removed in the next version. The result reports `source_height`.

    • output_formatany of

      Output format. Defaults to the input's format.

      Show 2 nested
      any of (2)
      Variant 1
      valuestringenum jpeg, png, webp
      Variant 2
      valuenull
    • qualityinteger· uint81…100

      JPEG and WebP quality. Ignored for PNG. Defaults to the configured quality.

    • strategyany of

      `scale-to-fit` fits the image inside the box; `crop-to-fit` centre-crops it to the box's aspect ratio, then shrinks it to the box. Defaults to the configured strategy.

      Show 2 nested
      any of (2)
      Variant 1
      valuestringenum scale-to-fit, crop-to-fit
      Variant 2
      valuenull
    • target_heightinteger· uint32min 1

      Box height in pixels. The image is never enlarged. Defaults to the configured box.

    • target_widthinteger· uint32min 1

      Box width in pixels. The image is never enlarged. Defaults to the configured box.

    • widthunknown

      Deprecated and ignored; removed in the next version. The result reports `source_width`.

    Variant 2
    valuenull
  • output_channelobjectrequired

    A stream the function writes: the ref of the write end of an engine pipe ({channel_id, access_key, direction: "write"}). The SDK opens it on first write.

    • access_keystringrequired
    • channel_idstringrequired
    • directionstringrequired
Response
  • formatstringrequiredenum jpeg, png, webp
  • heightinteger· uint32requiredmin 0
  • source_heightinteger· uint32requiredmin 0
  • source_widthinteger· uint32requiredmin 0
  • strategystringrequiredenum scale-to-fit, crop-to-fit
  • widthinteger· uint32requiredmin 0

Search the registry

Find workers, kits and executables, or jump to a page.