Transformation Methods
Apply transformations to images
Converts an image to a different format (jpeg, png, or webp).
convert(imageID: string, body: ImageConvertParams, options?: RequestOptions): APIPromise<ImageObject>;
The unique identifier of the image to convert.
The body parameters for converting the image.
const imageObject = await client.images.convert('image_etm0g3x5iap4cld1qcfsjvo2', { format: 'jpeg' });
Crops an image by specifying the dimensions of the crop area.
crop(imageID: string, body: ImageCropParams, options?: RequestOptions): APIPromise<ImageObject>;
The unique identifier of the image to crop.
The body parameters for cropping the image.
The x-coordinate of the top-left corner of the crop area.
The x-coordinate of the bottom-right corner of the crop area.
The y-coordinate of the top-left corner of the crop area.
The y-coordinate of the bottom-right corner of the crop area.
The name of the image to identify it on the dashboard.
const imageObject = await client.images.crop('image_etm0g3x5iap4cld1qcfsjvo2', { x1: 0, x2: 100, y1: 0, y2: 100 });
Mirrors an image horizontally or vertically.
mirror(imageID: string, body: ImageMirrorParams, options?: RequestOptions): APIPromise<ImageObject>;
const imageObject = await client.images.mirror('image_etm0g3x5iap4cld1qcfsjvo2', { mode: 'horizontal' });
Resizes an image, you can use fit
to specify how the image is resized.
resize(imageID: string, body: ImageResizeParams | null | undefined = {}, options?: RequestOptions): APIPromise<ImageObject>;
The unique identifier of the image to resize.
The body parameters for resizing the image.
The fit mode to use when resizing the image (cover, contain, or fill).
The height of the image to resize.
The color of the letterbox when using the contain fit mode.
The name of the image to identify it on the dashboard.
The gravity position of the image when using the cover or contain fit modes.
The width of the image to resize.
const imageObject = await client.images.resize('image_etm0g3x5iap4cld1qcfsjvo2', { width: 200, height: 200 });
Rotates an image by a specified angle.
rotate(imageID: string, body: ImageRotateParams, options?: RequestOptions): APIPromise<ImageObject>;
The unique identifier of the image to rotate.
const imageObject = await client.images.rotate('image_etm0g3x5iap4cld1qcfsjvo2', { angle: 90 });