Fetching contributors…
Cannot retrieve contributors at this time
166 lines (86 sloc) 7.13 KB


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 PHP, Cloudinary provides an extension for simplifying the integration even further.


1. Made code changes to implement cURL instead of HTTP Pecl for Upload.


Download cloudinary_php from here

Note: cloudinary_php require PHP 5.3

Try it right away

Sign up for a free account so you can try out image transformations and seamless image delivery through CDN.

Note: Replace demo in all the following examples with your Cloudinary's cloud name.

Accessing an uploaded image with the sample public ID through a CDN:


Generating a 150x100 version of the sample image and downloading it through a CDN:,h_100,c_fill/sample.jpg

Sample 150x100

Converting to a 150x100 PNG with rounded corners of 20 pixels:,h_100,c_fill,r_20/sample.png

Sample 150x150 Rounded PNG

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:,g_face,h_90,w_120/billclinton.jpg

Facebook 90x120

For more details, see our documentation for embedding Facebook and Twitter profile pictures.



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 calling the Cloudinary::config(), or by using the CLOUDINARY_URL environment variable.

Embedding and transforming images

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("sample.jpg", array("width" => 100, "height" => 150, "crop" => "fill"))

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

cloudinary_url("woman.jpg", array("width" => 90, "height" => 90, "crop" => "thumb", "gravity" => "face"))

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("billclinton.jpg", array("width" => 90, "height" => 130, "type" => "facebook", "crop" => "fill", "gravity" => "north_west"))

Same goes for Twitter:

cloudinary_url("billclinton.jpg", array("type" => "twitter_name"))


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:


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("", "public_id" => 'sample_remote')



Returns an html image tag pointing to Cloudinary.


<?php echo cl_image_tag("sample", array("format"=>"png", "width"=>100, "height"=>100, "crop"=>"fill") ?>

# <img src=',h_100,w_100/sample.png' height='100' width='100'/>


The following function returns an html form that can be used to upload the file directly to Cloudinary. The result is a redirect to the supplied callback_url.

cl_form_tag(callback, array(...))

Optional parameters:

public_id - The name of the uploaded file in Cloudinary
form - html attributes to be added to the form tag
Any other parameter that can be passed to \Cloudinary\Uploader::upload



To run the PHPUnit test suite you must first set the evnironment variable containing your Cloudinary URL. This can be obtained via Cloudinary's Management Console.

export CLOUDINARY_URL=cloudinary://123456789012345:abcdeghijklmnopqrstuvwxyz12@n07t21i7

Next you can run your the PHPUnit suite from the root of this library:

phpunit tests/*

Additional resources

Additional resources are available at:


You can open an issue through GitHub.

Contact us at

Or via Twitter: @cloudinary


Released under the MIT license.