Learn to get started with Cloudinary in a Node.js app. This tutorial covers setting up, configuring, and optimizing images using the Cloudinary Node.js SDK.
This video is brought to you by Cloudinary's video player - embed your own! Use the controls to set the playback speed, navigate to chapters of interest and select subtitles in your preferred language.
Discover the power of Cloudinary, a platform for image and video management that goes beyond simple uploads. Learn about features like background removal, dynamic cropping, resizing, and AI-driven content analysis in a Node.js app.
Install the Cloudinary Node.js SDK using your preferred package manager e.g., npm install cloudinary.
Import Cloudinary using const cloudinary = require('cloudinary').v2.
Configure your account using cloudinary.config(), where you’ll input your cloud_name, api_key, and api_secret. Learn how to find these credentials in your Cloudinary dashboard.
You can look for an image to deliver in your Media Library. There are some pre-uploaded ones or you can upload your own. Copy the public ID of the image to use in your script. Use the cloudinary.url() method to generate the delivery URL from the public ID.
To transform an image, add a second argument, transformation, to the url method, specifying different transformations. For example, fetch_format: 'auto' delivers the best format based on the browser, quality: 'auto' compresses the image as much as possible without visual impact, and width:1200 resizes the image on the server side, reducing the number of bytes to deliver.
To upload an image programmatically, you need to configure your API key and secret. Use environment variables to store these, as you shouldn't expose your API secret to anyone. Then you can use the cloudinary.uploader.upload() method to upload an image. For example, uploading a local image:
Check out the Cloudinary Academy for free self-paced Cloudinary courses on a variety of developer or DAM topics, or register for formal instructor-led courses, either virtual or on-site.
✔️ Feedback sent!
✖️
*
Cloudinary is committed to protecting your information security. For details, see our privacy policy.
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.