Get Started
IMG Processing Client
Transformation Methods
Apply transformations to images
Create a new image by converting an existing image to a different format.
The supported image formats are jpeg
, png
, and webp
.
convert<Format>(options: ConvertOptions<Format>): Promise<ImageObject<Format>;
The format to convert the image to. Supported formats are jpeg
, png
, and webp
.
The quality of the converted image if the target format is jpeg
.
The name of the image to identify it on the dashboard. If not provided, the name will be the same as the original image.
const converted = await image.convert({ format: 'png' });
Create a new image by cropping an existing image.
crop(options: CropOptions): Promise<ImageObject>;
The x-coordinate of the top-left corner of the crop area.
- The x-coordinate must be greater than or equal to 0.
The y-coordinate of the top-left corner of the crop area.
- The y-coordinate must be greater than or equal to 0.
The x-coordinate of the bottom-right corner of the crop area.
- The x-coordinate must be greater than the x-coordinate of the top-left corner.
The y-coordinate of the bottom-right corner of the crop area.
- The y-coordinate must be greater than the y-coordinate of the top-left corner.
The name of the image to identify it on the dashboard.
- The name must be between 1 and 30 characters long.
const croppedImage = await image.crop({ x1: 0, y1: 0, x2: 100, y2: 100 });
Create a new image by mirroring an existing image.
mirror(options: MirrorOptions): Promise<ImageObject>;
const mirroredImage = await image.mirror({ mode: 'horizontal' });
Create a new image by resizing an existing image.
resize(options: ResizeOptions): Promise<ImageObject>;
The desired width of the resized image in pixels.
- The width must be greater than 0.
The desired height of the resized image in pixels.
- The height must be greater than 0.
The color of the letterbox when using the contain
fit mode.
It can be a color name, a hex color code, or transparent
.
The gravity position of the image when using the cover
or contain
fit modes.
Available options: center
, top
, right
, bottom
, left
, top-right
, top-left
, bottom-right
, bottom-left
.
The fit mode to use when resizing the image.
Available options: fill
, contain
, cover
.
The name of the image to identify it on the dashboard.
- The name must be between 1 and 30 characters long.
const resizedImage = await image.resize({ width: 100, height: 100 });
Create a new image by rotating an existing image.
rotate(options: RotateOptions): Promise<ImageObject>;
const rotatedImage = await image.rotate({ angle: 90 });