Upload, transform, optimize, and manage images and videos with Cloudinary from Python or Django.
Actively maintained. Last release 4 weeks ago, commits in 6 of the last 26 weeks. A safe choice.
pip install cloudinaryCloudinary Python SDK
Upload, transform, optimize, and manage images and videos with Cloudinary from Python or Django — the cloudinary package on PyPI.
Install
pip install cloudinary
Quick start
Set your API environment variable (Console > Settings > API Keys):
export CLOUDINARY_URL=cloudinary://<api_key>:<api_secret>@<cloud_name>
Upload an image and get an optimized delivery URL:
import cloudinary
import cloudinary.uploader # cloudinary.uploader must be imported explicitly
# Configuration is read from CLOUDINARY_URL automatically.
def main():
# Upload a remote image (a local file path works the same way)
result = cloudinary.uploader.upload(
"https://res.cloudinary.com/demo/image/upload/sample.jpg",
public_id="quickstart-sample",
)
print("Uploaded: {0}".format(result["public_id"]))
# Build a 400x400 auto-cropped URL with automatic format and quality
url = cloudinary.CloudinaryImage(result["public_id"]).build_url(
width=400,
height=400,
crop="fill",
gravity="auto",
fetch_format="auto",
quality="auto",
secure=True,
)
print("Optimized URL: {0}".format(url))
if __name__ == "__main__":
try:
main()
except Exception as error:
print("Quick start failed: {0}".format(error))
print("Check that CLOUDINARY_URL is set (Console > Settings > API Keys).")
raise SystemExit(1)
Save as quickstart.py and run python quickstart.py. Create a free account if you don't have one — or call cloudinary.provisioning.create_cloud() to provision one without signing up.