MCPcopy Index your code
hub / github.com/cloudinary/cloudinary_java

github.com/cloudinary/cloudinary_java @2.3.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release 2.3.1 ↗ · + Follow
1,778 symbols 8,069 edges 145 files 305 documented · 17%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status

Cloudinary

About

The Cloudinary Java SDK allows you to quickly and easily integrate your application with Cloudinary. Effortlessly optimize and transform your cloud's assets.

Additional documentation

This Readme provides basic installation and usage information. For the complete documentation, see the Java SDK Guide.

Table of Contents

Key Features

Version Support

SDK Version Java 6+ Java 8
1.1.0 - 1.39.0 V
2.0.0+ V

Installation

The cloudinary_java library is available in Maven Central. To use it, add the following dependency to your pom.xml :

<dependency>
    <groupId>com.cloudinary</groupId>
    <artifactId>cloudinary-http45</artifactId>
    <version>2.3.1</version>
</dependency>

Usage

Setup

Each request for building a URL of a remote cloud resource must have the cloud_name parameter set. Each request to our secure APIs (e.g., image uploads, eager sprite generation) must have the api_key and api_secret parameters set. See API, URLs and access identifiers for more details.

Setting the cloud_name, api_key and api_secret parameters 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.

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:abcdeghijklmnopqrstuvwxyz12@n07t21i7");

Transform and Optimize Assets

  • See full documentation 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 sample image while transforming it to fill a 100x150 rectangle:

cloudinary.url().transformation(new Transformation().width(100).height(150).crop("fill")).generate("sample.jpg");

Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:

cloudinary.url().transformation(new Transformation().width(90).height(90).crop("thumb").gravity("face")).generate("woman.jpg");

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:

cloudinary.url().type("facebook").transformation(new Transformation().width(130).height(130).crop("fill").gravity("north_west")).generate("billclinton.jpg");

File upload

Assuming you have your Cloudinary configuration parameters defined (cloud_name, api_key, api_secret), uploading to Cloudinary is very simple.

The following example uploads a local JPG to the cloud:

cloudinary.uploader().upload("my_picture.jpg", ObjectUtils.emptyMap());

The uploaded image is assigned a randomly generated public ID. The image is immediately available for download through a CDN:

cloudinary.url().generate("abcfrmo8zul1mafopawefg.jpg");

# http://res.cloudinary.com/demo/image/upload/abcfrmo8zul1mafopawefg.jpg

You can also specify your own public ID:

cloudinary.uploader().upload("http://www.example.com/image.jpg", ObjectUtils.asMap("public_id", "sample_remote"));

cloudinary.url().generate("sample_remote.jpg");

# http://res.cloudinary.com/demo/image/upload/sample_remote.jpg

Contributions

See contributing guidelines.

Get Help

About Cloudinary

Cloudinary is a powerful media API for websites and mobile apps alike, Cloudinary enables developers to efficiently manage, transform, optimize, and deliver images and videos through multiple CDNs. Ultimately, viewers enjoy responsive and personalized visual-media experiences—irrespective of the viewing device.

Additional Resources

Licence

Released under the MIT license.

Extension points exported contracts — how you extend this code

ProgressCallback (Interface)
Defines a callback for network operations. [1 implementers]
cloudinary-core/src/main/java/com/cloudinary/ProgressCallback.java
TimeoutTest (Interface)
Marker interface for Junit categories.
cloudinary-test-common/src/main/java/com/cloudinary/test/TimeoutTest.java
PhotoRepository (Interface)
(no doc)
samples/photo_album/src/main/java/cloudinary/repositories/PhotoRepository.java
JSONString (Interface)
The JSONString interface allows a toJSONString() method so that a class can change the behavio
cloudinary-core/src/main/java/org/cloudinary/json/JSONString.java
ApiResponse (Interface)
(no doc) [2 implementers]
cloudinary-core/src/main/java/com/cloudinary/api/ApiResponse.java

Core symbols most depended-on inside this repo

get
called by 1021
cloudinary-core/src/main/java/org/cloudinary/json/JSONArray.java
put
called by 515
cloudinary-core/src/main/java/org/cloudinary/json/JSONArray.java
emptyMap
called by 245
cloudinary-core/src/main/java/com/cloudinary/utils/ObjectUtils.java
generate
called by 206
cloudinary-core/src/main/java/com/cloudinary/Url.java
append
called by 203
cloudinary-core/src/main/java/org/cloudinary/json/JSONObject.java
url
called by 192
cloudinary-core/src/main/java/com/cloudinary/Cloudinary.java
asMap
called by 192
cloudinary-core/src/main/java/com/cloudinary/utils/ObjectUtils.java
toString
called by 176
cloudinary-core/src/main/java/com/cloudinary/BaseParam.java

Shape

Method 1,590
Class 131
Function 47
Enum 5
Interface 5

Languages

Java97%
TypeScript3%

Modules by API surface

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java129 symbols
cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractApiTest.java87 symbols
cloudinary-core/src/main/java/com/cloudinary/Api.java83 symbols
cloudinary-taglib/src/main/java/com/cloudinary/taglib/CloudinaryUploadTag.java81 symbols
cloudinary-core/src/main/java/com/cloudinary/Transformation.java79 symbols
cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractUploaderTest.java56 symbols
cloudinary-core/src/main/java/org/cloudinary/json/JSONObject.java50 symbols
cloudinary-core/src/main/java/com/cloudinary/Url.java45 symbols
cloudinary-test-common/src/main/java/com/cloudinary/test/AbstractAccountApiTest.java41 symbols
cloudinary-core/src/main/java/com/cloudinary/Uploader.java37 symbols
cloudinary-core/src/main/java/com/cloudinary/Configuration.java36 symbols
samples/photo_album_gae/src/main/java/org/esxx/js/protocol/GAEClientConnection.java34 symbols

For agents

$ claude mcp add cloudinary_java \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact