GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||
GeezerVison is showing cloudinary.com — JavaScript Image Transformations | Documentation
Menu
JavaScript SDK image transformationsLast updated: Aug-17-2026 OverviewAfter you or your users have uploaded image assets to Cloudinary, you can deliver them via dynamic URLs. You can include instructions in your dynamic URLs that tell Cloudinary to transform your assets using a set of transformation parameters. All transformations are performed automatically in the cloud and your transformed assets are automatically optimized before they are routed through a fast CDN to the end user for optimal user experience. For example, you can resize and crop, add overlay images, blur or pixelate faces, apply a large variety of special effects and filters, and apply settings to optimize your images and to deliver them responsively. The If you haven't yet installed the JavaScript SDK, you might want to jump to the quick start first. See also: JavaScript video transformations Image transformations with JavaScriptTo transform a media asset, use the In the above example, the front_face image is cropped to a 150 x 150 pixel thumbnail with rounded corners, focusing on the face, resulting in this URL: The You can use the Transformation Builder reference to find all available transformations, syntax and examples. Alternative ways to apply transformationsThere are a couple of other ways to apply transformations to your images that you may prefer to use, for example if a new transformation is not yet supported by the SDK, or if you're more familiar with other SDKs. Note, however, that you won't benefit from your IDE's code completion feature for building the transformations in these ways. See also: Shortcuts and aliases for other ways to simplify the syntax. URL syntaxYou can add any transformation in URL syntax using the For example: This can be used together with other actions and qualifiers in the usual way. It's useful if a new transformation is added but not yet available in the SDK, or if you're just more familiar with the URL syntax. Object syntaxIf you prefer the more concise syntax used for transformations in the Node.js SDK, you can use the For example:
Note
The required JavaScript import for this syntax is likely to be heavier than importing the actions and qualifiers separately.Syntax overviewThe
The general form of the syntax is: An example being: Actions and ActionGroups
Qualifiers and QualifierValues
The output of each ActionGroup is a complete transformation component (separated by slashes) in the URL. For example, the syntax example above would generate the following URL: Tree shakingThe See the Transformation Builder reference for all actions and qualifiers. For example, if you import
Similarly, for qualifier values:
Most of the examples shown in this guide use tree shaking. Shortcuts and aliasesTo simplify some of the syntax, you can use string shortcuts for nested qualifiers. For example, rather than: you can say: Additionally, there are aliases for delivery format and quality, to shorten the syntax further. For example, the above can be shortened to: For quality, instead of: you can say: Deliver and transform imagesThe Direct URL buildingYou can build an image URL by:
The resulting URL, Specifying a version of your image to deliverYou can specify a particular version of your image to deliver by using the For example, to specify version The resulting URL is now: Specifying the delivery typeYou can change the delivery type from the default of For example, to define a The resulting URL is: Transforming your imageImages are transformed by adding serialized transformation instructions to the image delivery URL. For example, to scale your image to a width of 400 pixels, add
Using the
Tip
Discover alternative ways to apply transformations to your images.Chaining transformationsCloudinary transformations can be chained together (each transformation is applied to the result of the previous transformation). For example, the following code crops the image to 150x150, rounds the corners, applies a sepia effect, adds text to the top center of the resized image, then rotates the entire result by 20 degrees and delivers a PNG. The code above generates the following image delivery URL: Sample app: JavaScript image transformationsIn this JavaScript app, you can see all the transformations that are used throughout this guide. Each transformation example has its own JavaScript file showing the imports and syntax required. Here's the app in action:
The code for this app is available in GitHub.
Apply common image transformationsThis section provides an overview and examples of how to implement the following commonly used image transformation features using the
Keep in mind that this section is only intended to introduce you to the basics of using image transformations.
Tips
Resizing and croppingThere are a variety of different ways to resize and/or crop your images, and to control the area of the image that is preserved during a crop. The following example uses the You can also use automatic gravity to determine what to keep in the crop automatically. For details on all resizing and cropping options, see resizing and cropping images. Converting to another image formatYou can deliver any image uploaded to Cloudinary in essentially any image format. There are three main ways to convert and deliver in another format:
For example: 1. To deliver a .jpg file in .gif format:
2. To let Cloudinary select the optimal format for each browser, set This is the returned URL: For more details, see:
Applying image effects and filtersYou can select from a large selection of image effects, enhancements, and filters to apply to your images. The available effects include a variety of color balance and level effects, tinting, blurring, pixelating, sharpening, automatic improvement effects, artistic filters, image and text overlays, distortion and shape changing effects, outlines, backgrounds, shadows, and more. For example, the code below applies a cartoonify effect, rounding corners effect, and background color effect (and then scales the image down to a height of 300 pixels). For more details on the available image effects and filters, see Visual image effects and enhancements. Adding text and image overlaysYou can add images and text as overlays on your main image. You can apply the same types of transformations on your overlay images as you can with any image and you can use gravity settings or x and y coordinates to control the location of the overlays. You can also apply a variety of transformations on text, such as color, font, size, rotation, and more. For example, the code below overlays a couple's photo on a mug image. The overlay photo is cropped using face detection with adjusted color saturation and a vignette effect applied. The word love is added in a pink, fancy font and rotated to fit the design. A balloon graphic is also added. Additionally, the final image is cropped and the corners are rounded.
Tip
Although at first glance this example may look complicated, take the time to look through the code and you'll see it's actually quite intuitive!Image optimizationsBy default, Cloudinary automatically performs certain optimizations on all transformed images. There are also a number of additional features that enable you to further optimize the images you use in your JavaScript application. These include optimizations to image quality, format, and size, among others. For example, you can use the For an in-depth review of the many ways you can optimize your images, see Image optimization. PluginsThe
Both lazy loading and image placeholders are great techniques for helping to optimize your page load times and, in turn, improve your metrics related to Core Web Vitals. First, install the Then, use the required plugins in an The following sections explain each of the plugins in more detail, but you can also jump straight to a full example to start playing. Plugin orderWe recommend the following order when using our plugins to achieve the best results (omitting any you don't need): Lazy loadingLazy loading tells the browser not to download images that are not yet visible on the user's screen, and wait until the user scrolls to that image. This feature can potentially save bandwidth for images that are not actually viewed, and decrease the time needed to load a page. This video shows lazy loading in action. See how the GET request is triggered only when the image is starting to come into the viewport:
To enable the lazy loading feature for a particular image, use the Example: Set root margin and thresholdLoad an image when 25% of it is visible. Specify a bounding box around the root element with margins, top: 10px, right: 20px, bottom: 10px, left: 30px:
Note
To avoid your page content 'jumping' as the elements dynamically adjust to add downloaded images, make sure to add height and width attributes to the img element.Responsive imagesYou can make your images responsive, so that they automatically resize based on the viewport size. If the viewport is small, then a small image is requested, saving bytes and reducing page load times. This video shows responsive image behavior in action. See how a new image is requested when the browser is resized, based on the configured step size:
To enable the responsive images feature for a particular image, use the Example 1: Set step sizeSet the step size to 200 pixels: Example 2: Specify a set of image widths to useSpecify a set of image widths (800, 1000 and 1400 pixels): Image accessibilityThis feature makes an image more accessible to users by specifying one of the following modes:
To enable the accessibility feature for a particular image, use the Example: Apply an accessibility transformationHelp color blind users by using the Image placeholdersAn image placeholder is a lightweight version of a target image that can be downloaded quickly, and will occupy the same location as the intended target image, while the target image is still downloading. Once the target image download has been completed the placeholder is replaced with the final image. This feature is especially useful together with large images. Placeholder images offer the following features:
You can specify four different types of placeholder:
To add a placeholder for a particular image, use the Example 1: Apply a placeholder transformationUse a blurred placeholder image while waiting for the full quality image to download: Example 2: Combine lazy loading with a placeholderYou can also combine placeholder images with the lazy loading feature. In this case, when the user scrolls to the image location, the placeholder image is downloaded followed by the target image. For example, to use a solid, single-color placeholder image and the lazy loading feature: In this video, you can see all the different placeholder types combined with lazy loading:
Sample app: JavaScript pluginsSee the plugins in action in this JavaScript app:
The code for this app is available in GitHub.
✔️ Feedback sent!
✖️
*
Cloudinary is committed to protecting your information security. For details, see our privacy policy. For additional assistance, open a support request. ErrorUnfortunately there's been an error sending your feedback. Rate this page: | ||||||||||||||||||||
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |