Modern websites and mobile apps frequently showcase images of various dimensions, sometimes varying the graphics, resolutions, and look and feel for different devices (desktop, mobile, etc.); and revamping the graphics with upgrades.
A key benefit Cloudinary offers is an easy, intuitive, and flexible process of modifying images. A case in point: by setting simple parameters in our dynamic URLs, you can resize or crop images, alter their shapes, and apply effects. After transforming images on the fly in the cloud and optimizing the resulting thumbnails, Cloudinary delivers them through a fast content delivery network (CDN).
Signed URLs are integral to this process. They include essential components like authentication information, a hash value, and an expiration date/time, ensuring that each URL is valid only for a specific period. This time-limited access feature is crucial for maintaining the security and integrity of the images, especially in scenarios where access needs to be controlled and monitored.
All that makes it a snap to view the various images derived from a single high-resolution source. Here’s an example of a dynamic image-transformation URL in action:
Cloudinary’s dynamic URLs can also fetch, transform, and deliver Facebook or Twitter profile pictures—in fact, any image with a public URL. For example:
The above approach lacks security, however: anyone could delete a parameter, such as that for a watermark, by tweaking the image’s dynamic URL.
Besides image transformations, signed URLs can be used to prevent unauthorized viewers from downloading content and to prevent embedding a player on sites not owned by the content provider. This signed URL application is useful for controlling where and how content is displayed and accessed.
To prevent arbitrary image fetches and edits, you can transform images while uploading them to Cloudinary or enable Cloudinary’s strict-transformations mode to limit the number of transformations. However, because those are manual tasks that require working with authenticated APIs, you lose some of the flexibility in image transformation. A better alternative is to secure your images.
To that end, check out Cloudinary’s signed image URLs, which impose a higher degree of security while retaining the capabilities of dynamic flexible URLs.
Cloudinary’s signed image URLs dynamically validate image signatures before display. Creating those URLs after enabling the Strict Transformations setting on your Cloudinary account’s Settings page limits access to specific transformations and presigned URLs.
It’s important to note that alternatives like signed cookies can provide similar functionality. Signed cookies offer time-limited resource access to files, much like signed URLs. However, using signed URLs in image management is often more practical for individual files, especially when dealing with images sourced from various platforms.
For example, take this scaled-down thumbnail, which is sourced from an image uploaded to Cloudinary:
To create a signed URL for the image (sometimes called signed images for short), set the ‘sign_url‘ parameter to ‘true‘ when building the URL or creating an image tag. The following Ruby on Rails example creates an image tag of a 300×200-pixel, center-cropped thumbnail of the original image and signs the generated URL:
With the above setup, an attempt to apply a different transformation or add an invalid signature results in a 401 error message with the appropriate `X-Cld-Error` HTTP-header response, such as this one:
Behind the scenes, a Cloudinary client-integration SDK creates the signature component in the format `/s–SIGNATURE–/`, which is a Base64 encoding of a SHA-1 digest of your image’s public ID and transformation string, concatenated with your API secret. If Cloudinary has already or is set to apply the transformation in question, Cloudinary skips the signature check and the signature itself can be omitted.
You can pull original images with fetch URLs on Cloudinary. Concatenating a public image’s URL and Cloudinary’s delivery URL fetches the original image, transforms; optimizes, and caches it; ultimately delivering the final version through a CDN.
Tip: To prevent dynamic fetching of images from arbitrary domains, go to your Cloudinary account’s Settings page, click the Security tab near the top, and select Fetched URL under Restricted media types.
Additionally, by signing fetch URLs, you bypass the strict list of fetch domains and reap the dynamicity benefit of those URLs. As a demo, the following Django code generates an image tag of a signed URL that dynamically fetches a remote image from Wikipedia:
Also, if you must fetch and transform images from different locations, signed URLs enable you to stay strict without having to manually update your Cloudinary configurations or use the authenticated APIs. For instance, this slightly more complex Node.js example generates a signed URL of a resized, fetched image, applies effects, and adds a watermark:
Coupled with a signature-based security mechanism, Cloudinary’s dynamic, flexible image-fetching and transforming URLs are your answer for effective image management. You can embed any image in your website, create a responsive design with dynamic dimensions, and update it any time by changing the intuitive and simple URL parameters in your code. All the tasks are secure and abuse proof.
Recall that Cloudinary’s client SDKs create signed URLs by automatically generating the signature for you. Ensure that you’re running the latest versions of the SDKs:
One of the key advantages of generative AI is its ability to transform raw images into polished, professional visuals with minimal effort. Whether you’re removing backgrounds from product images, enhancing user-generated content, or adjusting product colors, AI takes care of the heavy lifting. In this blog, you’ll learn how…