Cloudinary Java Client Library
Cloudinary is a cloud service that offers a solution to a web application's entire image management pipeline.
Easily upload images to the cloud. Automatically perform smart image resizing, cropping and conversion without installing any complex software. Integrate Facebook or Twitter profile image extraction in a snap, in any dimension and style to match your website’s graphics requirements. Images are seamlessly delivered through a fast CDN, and much much more.
Cloudinary offers comprehensive APIs and administration capabilities and is easy to integrate with any web application, existing or new.
Cloudinary provides URL and HTTP based APIs that can be easily integrated with any Web development framework.
For Java, Cloudinary provides a library for simplifying the integration even further.
Take a look at our Getting started guide for Java.
The cloudinary_java library is available in Maven Central. To use it, add the following dependency to your pom.xml :
com.cloudinary cloudinary-http44 1.29.0
Sign up for a free account so you can try out image transformations and seamless image delivery through CDN.
demoin all the following examples with your Cloudinary's
Accessing an uploaded image with the
samplepublic ID through a CDN:
Generating a 150x100 version of the
sampleimage and downloading it through a CDN:
Converting to a 150x100 PNG with rounded corners of 20 pixels:
For plenty more transformation options, see our image transformations documentation.
Generating a 120x90 thumbnail based on automatic face detection of the Facebook profile picture of Bill Clinton:
Each request for building a URL of a remote cloud resource must have the
cloud_nameparameter set. Each request to our secure APIs (e.g., image uploads, eager sprite generation) must have the
api_secretparameters set. See API, URLs and access identifiers for more details.
api_secretparameters can be done either directly in each call to a Cloudinary method, by when initializing the Cloudinary object, or by using the CLOUDINARY_URL environment variable / system property.
The entry point of the library is the Cloudinary object.
java Cloudinary cloudinary = new Cloudinary();
Here's an example of setting the configuration parameters programatically:
Map config = new HashMap(); config.put("cloud_name", "n07t21i7"); config.put("api_key", "123456789012345"); config.put("api_secret", "abcdeghijklmnopqrstuvwxyz12"); Cloudinary cloudinary = new Cloudinary(config);
Another example of setting the configuration parameters by providing the CLOUDINARY_URL value to the constructor:
Cloudinary cloudinary = new Cloudinary("cloudinary://123456789012345:[email protected]");
Any image uploaded to Cloudinary can be transformed and embedded using powerful view helper methods:
The following example generates the url for accessing an uploaded
sampleimage while transforming it to fill a 100x150 rectangle:
Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:
You can provide either a Facebook name or a numeric ID of a Facebook profile or a fan page.
Embedding a Facebook profile to match your graphic design is very simple:
Same goes for Twitter:
See our documentation for more information about displaying and transforming images in Java.
Assuming you have your Cloudinary configuration parameters defined (
api_secret), uploading to Cloudinary is very simple.
The following example uploads a local JPG to the cloud:
The uploaded image is assigned a randomly generated public ID. The image is immediately available for download through a CDN:
You can also specify your own public ID:
cloudinary.uploader().upload("http://www.example.com/image.jpg", ObjectUtils.asMap("public_id", "sample_remote"));
See our documentation for plenty more options of uploading to the cloud from your Java code.
Returns an html image tag pointing to Cloudinary.
Returns an html input field for direct image upload, to be used in conjunction with cloudinary_js package. It integrates jQuery-File-Upload widget and provides all the necessary parameters for a direct upload.
Map options = ObjectUtils.asMap("resource_type", "auto"); Map htmlOptions = ObjectUtils.asMap("alt", "sample"); String html = cloudinary.uploader().imageUploadTag("image_id", options, htmlOptions);
See our documentation for plenty more options of uploading directly from the browser.
Additional resources are available at:
You can open an issue through GitHub.
Contact us https://cloudinary.com/contact
Impact the product, hear updates, test drive new features and more! Join here.
Released under the MIT license.