> ## Documentation Index
> Fetch the complete documentation index at: https://docs.img-processing.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Transformation Methods

> Apply transformations to images

<ResponseField name="convert">
  Converts an image to a different format (jpeg, png, or webp).

  <CodeGroup>
    ```typescript node-sdk theme={null}
    convert(imageID: string, body: ImageConvertParams, options?: RequestOptions): APIPromise<ImageObject>;
    ```
  </CodeGroup>

  <Expandable title="convertOptions">
    <ResponseField name="imageID" type="string" required>
      The unique identifier of the image to convert.
    </ResponseField>

    <ResponseField name="body" type="object" required>
      The body parameters for converting the image.

      <Expandable title="ImageConvertParams">
        <ResponseField name="format" type="string" required>
          The format to convert the image to (jpeg, png, webp).
        </ResponseField>

        <ResponseField name="name" type="string">
          The name of the image to identify it on the dashboard.
        </ResponseField>

        <ResponseField name="quality" type="number">
          The quality of the image to convert. It is a number between 1 and 100. If not provided, a default quality will be used.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  <Expandable title="Examples">
    <CodeGroup>
      ```typescript node-sdk theme={null}
      const imageObject = await client.images.convert('image_etm0g3x5iap4cld1qcfsjvo2', { format: 'jpeg' });
      ```
    </CodeGroup>
  </Expandable>
</ResponseField>

<ResponseField name="crop">
  Crops an image by specifying the dimensions of the crop area.

  <CodeGroup>
    ```typescript node-sdk theme={null}
    crop(imageID: string, body: ImageCropParams, options?: RequestOptions): APIPromise<ImageObject>;
    ```
  </CodeGroup>

  <Expandable title="cropOptions">
    <ResponseField name="imageID" type="string" required>
      The unique identifier of the image to crop.
    </ResponseField>

    <ResponseField name="body" type="object" required>
      The body parameters for cropping the image.

      <Expandable title="ImageCropParams">
        <ResponseField name="x1" type="number" required>
          The x-coordinate of the top-left corner of the crop area.
        </ResponseField>

        <ResponseField name="x2" type="number" required>
          The x-coordinate of the bottom-right corner of the crop area.
        </ResponseField>

        <ResponseField name="y1" type="number" required>
          The y-coordinate of the top-left corner of the crop area.
        </ResponseField>

        <ResponseField name="y2" type="number" required>
          The y-coordinate of the bottom-right corner of the crop area.
        </ResponseField>

        <ResponseField name="name" type="string">
          The name of the image to identify it on the dashboard.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  <Expandable title="Examples">
    <CodeGroup>
      ```typescript node-sdk theme={null}
      const imageObject = await client.images.crop('image_etm0g3x5iap4cld1qcfsjvo2', { x1: 0, x2: 100, y1: 0, y2: 100 });
      ```
    </CodeGroup>
  </Expandable>
</ResponseField>

<ResponseField name="mirror">
  Mirrors an image horizontally or vertically.

  <CodeGroup>
    ```typescript node-sdk theme={null}
    mirror(imageID: string, body: ImageMirrorParams, options?: RequestOptions): APIPromise<ImageObject>;
    ```
  </CodeGroup>

  <Expandable title="mirrorOptions">
    <ResponseField name="imageID" type="string" required>
      The unique identifier of the image to mirror.
    </ResponseField>

    <ResponseField name="body" type="object" required>
      The body parameters for mirroring the image.

      <Expandable title="ImageMirrorParams">
        <ResponseField name="mode" type="string" required>
          The mode of mirroring (horizontal, vertical, or both).
        </ResponseField>

        <ResponseField name="name" type="string">
          The name of the image to identify it on the dashboard.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  <Expandable title="Examples">
    <CodeGroup>
      ```typescript node-sdk theme={null}
      const imageObject = await client.images.mirror('image_etm0g3x5iap4cld1qcfsjvo2', { mode: 'horizontal' });
      ```
    </CodeGroup>
  </Expandable>
</ResponseField>

<ResponseField name="resize">
  Resizes an image, you can use `fit` to specify how the image is resized.

  <CodeGroup>
    ```typescript node-sdk theme={null}
    resize(imageID: string, body: ImageResizeParams | null | undefined = {}, options?: RequestOptions): APIPromise<ImageObject>;
    ```
  </CodeGroup>

  <Expandable title="resizeOptions">
    <ResponseField name="imageID" type="string" required>
      The unique identifier of the image to resize.
    </ResponseField>

    <ResponseField name="body" type="object">
      The body parameters for resizing the image.

      <Expandable title="ImageResizeParams">
        <ResponseField name="fit" type="string">
          The fit mode to use when resizing the image (cover, contain, or fill).
        </ResponseField>

        <ResponseField name="height" type="number">
          The height of the image to resize.
        </ResponseField>

        <ResponseField name="letterbox_color" type="string">
          The color of the letterbox when using the contain fit mode.
        </ResponseField>

        <ResponseField name="name" type="string">
          The name of the image to identify it on the dashboard.
        </ResponseField>

        <ResponseField name="position" type="string">
          The gravity position of the image when using the cover or contain fit modes.
        </ResponseField>

        <ResponseField name="width" type="number">
          The width of the image to resize.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  <Expandable title="Examples">
    <CodeGroup>
      ```typescript node-sdk theme={null}
      const imageObject = await client.images.resize('image_etm0g3x5iap4cld1qcfsjvo2', { width: 200, height: 200 });
      ```
    </CodeGroup>
  </Expandable>
</ResponseField>

<ResponseField name="rotate">
  Rotates an image by a specified angle.

  <CodeGroup>
    ```typescript node-sdk theme={null}
    rotate(imageID: string, body: ImageRotateParams, options?: RequestOptions): APIPromise<ImageObject>;
    ```
  </CodeGroup>

  <Expandable title="rotateOptions">
    <ResponseField name="imageID" type="string" required>
      The unique identifier of the image to rotate.
    </ResponseField>

    <ResponseField name="body" type="object" required>
      The body parameters for rotating the image.

      <Expandable title="ImageRotateParams">
        <ResponseField name="angle" type="number" required>
          The angle in degrees or radians to rotate the image.
        </ResponseField>

        <ResponseField name="name" type="string">
          The name of the image to identify it on the dashboard.
        </ResponseField>

        <ResponseField name="unit" type="string">
          The unit of the angle (degrees or radians). Defaults to degrees if not provided.
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>

  <Expandable title="Examples">
    <CodeGroup>
      ```typescript node-sdk theme={null}
      const imageObject = await client.images.rotate('image_etm0g3x5iap4cld1qcfsjvo2', { angle: 90 });
      ```
    </CodeGroup>
  </Expandable>
</ResponseField>
