1. Tasks
  2. Manipulate Image

Tasks

Manipulate Image

Transforms images through operations such as crop, resize, rotate, quality adjustment, and grayscale conversion, and converts images between file formats. Useful for media cleanup, thumbnails, and image-processing workflows.

Use Cases

  • Rotating images that are not oriented correctly to allow for better LLM understanding.
  • Reducing image quality to reduce image filesize and optimize storage.
  • Cropping images to focus on specific regions of interest.
  • Resizing images to meet specific dimension requirements.
  • Converting images to grayscale for document processing or analysis.
  • Converting images to a different file format, such as an SVG logo to a PNG that can be sent on WhatsApp or added to a PDF.

Basic usage

loading...

Parameters

files
required
object[]

An array of file objects. Each object contains file metadata.

Show child attributes
fileuuid
required
string

The unique identifier of the image file that should be manipulated.


operations
optional
object

An object containing the manipulation operations to perform on the image. You can specify one or more operations. Required unless output_settings is provided. Available operations:

Show child attributes

crop

optional
object

Crops the image to specified dimensions and offset.

  • width
    number
    - Width of the cropped area in pixels
  • height
    number
    - Height of the cropped area in pixels
  • x_offset
    number
    - Horizontal offset from the top-left corner in pixels
  • y_offset
    number
    - Vertical offset from the top-left corner in pixels

rotate

optional
object

Rotates the image by the specified degrees.

  • degrees
    number
    - Rotation angle in degrees (e.g., 90, 180, 270)

resize

optional
object

Resizes the image to specified dimensions.

  • width
    number
    - New width in pixels
  • height
    number
    - New height in pixels

adjust_quality

optional
object

Adjusts the image quality/compression level.

  • quality
    number
    - Quality level from 1-100, where 100 is highest quality

grayscale

optional
boolean

Converts the image to grayscale when set to true.


output_settings
optional
object

The details of the files to create. Use this to convert images to a different file format. The conversion happens after all operations have been applied.

If omitted, each image keeps its original format. SVG images are the exception, they are always output as PNG.

Show child attributes
content_type
required
string

The type of file to produce. The file extension of each image is changed to match, for example logo.svg becomes logo.png.

Supported: image/png | image/jpeg | image/webp | image/avif | image/gif | image/tiff

JPEG and TIFF do not support transparency, so any transparent areas are filled with white.

To set the size of a converted SVG, add a resize operation. The SVG is drawn at the new size, so it stays sharp at any size.


Result

loading...

Properties

images
array

An array of file objects representing the manipulated images. Each object contains:

  • filename
    string
    - The filename of the manipulated image
  • originalname
    string
    - The original filename
  • fileuuid
    string
    - The unique identifier of the manipulated image file
  • contentType
    string
    - The MIME type of the image

Examples

Rotate an image 90 degrees

Rotates an uploaded image 90 degrees clockwise.

loading...

Reduce image quality for optimization

Reduces the image quality to 50% to decrease file size.

loading...

Crop and resize an image

Crops a specific region from an image and then resizes it.

loading...

Convert to grayscale for document processing

Converts an image to grayscale and reduces quality for document processing workflows.

loading...

Convert an SVG to a PNG

Converts an SVG image to a PNG without changing anything else about the image.

loading...

Multiple operations on an image

Applies multiple manipulation operations: rotation, cropping, resizing, quality adjustment, and grayscale conversion.

loading...