Skip to content

Files

Latest commit

48c45b6 · Jun 15, 2025

History

History
421 lines (312 loc) · 39.7 KB

File metadata and controls

421 lines (312 loc) · 39.7 KB

Transformations

(transformations)

Overview

Enables you to manage named and unnamed transformations.

Available Operations

listTransformations

Retrieves a list of all transformations, which can be filtered to show either only named or unnamed transformations.

Example Usage

import { CloudinaryEnvConfig } from "@cloudinary/environment-config";

const cloudinaryEnvConfig = new CloudinaryEnvConfig({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const result = await cloudinaryEnvConfig.transformations.listTransformations(20, "8edbc61040178db60b0973ca9494bf3a");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CloudinaryEnvConfigCore } from "@cloudinary/environment-config/core.js";
import { transformationsListTransformations } from "@cloudinary/environment-config/funcs/transformationsListTransformations.js";

// Use `CloudinaryEnvConfigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const cloudinaryEnvConfig = new CloudinaryEnvConfigCore({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const res = await transformationsListTransformations(cloudinaryEnvConfig, 20, "8edbc61040178db60b0973ca9494bf3a");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("transformationsListTransformations failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
named boolean Whether to return only named (true) or unnamed (false) transformations. If this parameter isn't included, both named and unnamed transformations will be returned.
maxResults number Maximum number of transformations to return. [object Object]
nextCursor string When a request has more results to return than max_results, the next_cursor value is returned as part of the response. You can then specify this value as the next_cursor parameter of a following request. [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.ListResponse>

Errors

Error Type Status Code Content Type
errors.ApiError 400, 401, 403 application/json
errors.SDKError 4XX, 5XX */*

getTransformation

Retrieves details for a named or unnamed transformation.

Example Usage

import { CloudinaryEnvConfig } from "@cloudinary/environment-config";

const cloudinaryEnvConfig = new CloudinaryEnvConfig({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const result = await cloudinaryEnvConfig.transformations.getTransformation("small_profile_thumbnail");

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CloudinaryEnvConfigCore } from "@cloudinary/environment-config/core.js";
import { transformationsGetTransformation } from "@cloudinary/environment-config/funcs/transformationsGetTransformation.js";

// Use `CloudinaryEnvConfigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const cloudinaryEnvConfig = new CloudinaryEnvConfigCore({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const res = await transformationsGetTransformation(cloudinaryEnvConfig, "small_profile_thumbnail");
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("transformationsGetTransformation failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
transformation string ✔️ The transformation identifier. Can be either a named transformation (e.g., 'small_profile_thumbnail') or a transformation string (e.g., 'w_100,h_150,c_fill,g_auto').
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<components.TransformationInfo>

Errors

Error Type Status Code Content Type
errors.ApiError 400, 401, 403, 404 application/json
errors.SDKError 4XX, 5XX */*

createTransformation

Creates a new named transformation with the given name and transformation string.

Example Usage

import { CloudinaryEnvConfig } from "@cloudinary/environment-config";

const cloudinaryEnvConfig = new CloudinaryEnvConfig({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const result = await cloudinaryEnvConfig.transformations.createTransformation("small_profile_thumbnail", {
    transformation: "w_100,h_150,c_fill,g_auto",
    allowedForStrict: true,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CloudinaryEnvConfigCore } from "@cloudinary/environment-config/core.js";
import { transformationsCreateTransformation } from "@cloudinary/environment-config/funcs/transformationsCreateTransformation.js";

// Use `CloudinaryEnvConfigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const cloudinaryEnvConfig = new CloudinaryEnvConfigCore({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const res = await transformationsCreateTransformation(cloudinaryEnvConfig, "small_profile_thumbnail", {
    transformation: "w_100,h_150,c_fill,g_auto",
    allowedForStrict: true,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("transformationsCreateTransformation failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
transformation string ✔️ The valid transformation name to create.
[object Object]
createRequest components.CreateRequest ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.CreateTransformationResponse>

Errors

Error Type Status Code Content Type
errors.ApiError 400, 401, 403, 409 application/json
errors.SDKError 4XX, 5XX */*

updateTransformation

Update an existing named or unnamed transformation.

Example Usage

import { CloudinaryEnvConfig } from "@cloudinary/environment-config";

const cloudinaryEnvConfig = new CloudinaryEnvConfig({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const result = await cloudinaryEnvConfig.transformations.updateTransformation("small_profile_thumbnail", {
    unsafeUpdate: "w_200,h_200,c_fill,g_face",
    allowedForStrict: true,
  });

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CloudinaryEnvConfigCore } from "@cloudinary/environment-config/core.js";
import { transformationsUpdateTransformation } from "@cloudinary/environment-config/funcs/transformationsUpdateTransformation.js";

// Use `CloudinaryEnvConfigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const cloudinaryEnvConfig = new CloudinaryEnvConfigCore({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const res = await transformationsUpdateTransformation(cloudinaryEnvConfig, "small_profile_thumbnail", {
    unsafeUpdate: "w_200,h_200,c_fill,g_face",
    allowedForStrict: true,
  });
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("transformationsUpdateTransformation failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description
transformation string ✔️ The transformation identifier. Can be either a named transformation (e.g., 'small_profile_thumbnail') or a transformation string (e.g., 'w_100,h_150,c_fill,g_auto').
updateRequest components.UpdateRequest ✔️ N/A
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.UpdateTransformationResponse>

Errors

Error Type Status Code Content Type
errors.ApiError 400, 401, 403 application/json
errors.SDKError 4XX, 5XX */*

deleteTransformation

Delete a named or unnamed transformation. Optionally invalidate derived resources generated using the named transformation.

Example Usage

import { CloudinaryEnvConfig } from "@cloudinary/environment-config";

const cloudinaryEnvConfig = new CloudinaryEnvConfig({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const result = await cloudinaryEnvConfig.transformations.deleteTransformation("small_profile_thumbnail", true);

  console.log(result);
}

run();

Standalone function

The standalone function version of this method:

import { CloudinaryEnvConfigCore } from "@cloudinary/environment-config/core.js";
import { transformationsDeleteTransformation } from "@cloudinary/environment-config/funcs/transformationsDeleteTransformation.js";

// Use `CloudinaryEnvConfigCore` for best tree-shaking performance.
// You can create one instance of it to use across an application.
const cloudinaryEnvConfig = new CloudinaryEnvConfigCore({
  cloudName: "<value>",
  security: {
    apiKey: "CLOUDINARY_API_KEY",
    apiSecret: "CLOUDINARY_API_SECRET",
  },
});

async function run() {
  const res = await transformationsDeleteTransformation(cloudinaryEnvConfig, "small_profile_thumbnail", true);
  if (res.ok) {
    const { value: result } = res;
    console.log(result);
  } else {
    console.log("transformationsDeleteTransformation failed:", res.error);
  }
}

run();

Parameters

Parameter Type Required Description Example
transformation string ✔️ The transformation identifier. Can be either a named transformation (e.g., 'small_profile_thumbnail') or a transformation string (e.g., 'w_100,h_150,c_fill,g_auto').
invalidate boolean Invalidate derived resources generated using the deleted transformation from CDN. [object Object]
options RequestOptions Used to set various options for making HTTP requests.
options.fetchOptions RequestInit Options that are passed to the underlying HTTP request. This can be used to inject extra headers for examples. All Request options, except method and body, are allowed.
options.retries RetryConfig Enables retrying HTTP requests under certain failure conditions.

Response

Promise<operations.DeleteTransformationResponse>

Errors

Error Type Status Code Content Type
errors.ApiError 400, 401, 403, 404 application/json
errors.SDKError 4XX, 5XX */*