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 projects based on Microsoft .NET Framrwork, Cloudinary provides a library for simplifying the integration even further.
Take a look at our Getting started guide for .NET.
CloudinaryDotNet is available as NuGet package at https://nuget.org/packages/CloudinaryDotNet
Please see NuGet Documentation at http://docs.nuget.org/ for instructions of how to work with NuGet packages.
- Download NuGet Package Manager at http://visualstudiogallery.msdn.microsoft.com/27077b70-9dad-4c64-adcf-c7cf6bc9970c
- Use Visual Studio to create a new project and choose .NET 3.5 as the target framework.
- Right click on the project in Solution Explorer and click on Manage NuGet packages...
- Type CloudinaryDotNet in the search box at the upper right corner.
- When CloudinaryDotNet package appears, click on the Install button.
- After the package is installed click Close button.
- Setup is done and you can now use CloudinaryDotNet.
- Go to https://nuget.org/packages/CloudinaryDotNet and download NuGet package.
- NuGet package is a ZIP archive that could be extracted using any unzip tool.
- NuGet package contains CloudinaryDotNet.dll, xml documentation and this file.
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:
http://res.cloudinary.com/demo/image/upload/sample.jpg
Generating a 150x100 version of the sample
image and downloading it through a CDN:
http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill/sample.jpg
Converting to a 150x100 PNG with rounded corners of 20 pixels:
http://res.cloudinary.com/demo/image/upload/w_150,h_100,c_fill,r_20/sample.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:
http://res.cloudinary.com/demo/image/facebook/c_thumb,g_face,h_90,w_120/billclinton.jpg
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 when initializing the Cloudinary object, or by using the CLOUDINARY_URL environment variable / system property.
The main entry point of the library is the Cloudinary object.
CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary();
NOTE: This call assumes that CLOUDINARY_URL environment variable is set. If not, please use parameterized constructor:
CloudinaryDotNet.Account account =
new CloudinaryDotNet.Account("my_cloud_name", "my_api_key", "my_api_secret");
CloudinaryDotNet.Cloudinary cloudinary = new CloudinaryDotNet.Cloudinary(account);
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:
string url = cloudinary.Api.UrlImgUp.Transform(new CloudinaryDotNet.Transformation().Width(100).Height(150).Crop("fill")).BuildUrl("sample.jpg");
Another example, emedding a smaller version of an uploaded image while generating a 90x90 face detection based thumbnail:
string url = cloudinary.Api.UrlImgUp.Transform(new CloudinaryDotNet.Transformation().Width(90).Height(90).Crop("thumb").Gravity("face")).BuildUrl("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:
string url = cloudinary.Api.UrlImgUp.Action("facebook").Transform(new CloudinaryDotNet.Transformation().Width(130).Height(130).Crop("fill").Gravity("north_west")).BuildUrl("billclinton.jpg");
Same goes for Twitter:
string url = cloudinary.Api.UrlImgUp.Action("twitter_name").BuildUrl("billclinton.jpg");
See our documentation for more information about displaying and transforming images in .NET.
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:
CloudinaryDotNet.Actions.ImageUploadParams uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams()
{
File = new CloudinaryDotNet.Actions.FileDescription(@"c:\mypicture.jpg")
};
CloudinaryDotNet.Actions.ImageUploadResult uploadResult = cloudinary.Upload(uploadParams);
The uploaded image is assigned a randomly generated public ID. The image is immediately available for download through a CDN:
string url = cloudinary.Api.UrlImgUp.BuildUrl(String.Format("{0}.{1}", uploadResult.PublicId, uploadResult.Format));
http://res.cloudinary.com/cloud_name/image/upload/biricaezlhduexarhzsb.jpg
You can also specify your own public ID:
CloudinaryDotNet.Actions.ImageUploadParams uploadParams = new CloudinaryDotNet.Actions.ImageUploadParams()
{
File = new CloudinaryDotNet.Actions.FileDescription(@"c:\mypicture.jpg"),
PublicId = "sample_remote_file"
};
CloudinaryDotNet.Actions.ImageUploadResult uploadResult = cloudinary.Upload(uploadParams);
string url = cloudinary.Api.UrlImgUp.BuildUrl("sample_remote_file.jpg");
http://res.cloudinary.com/cloud_name/image/upload/sample_remote_file.jpg
See our documentation for plenty more options of uploading to the cloud from your .NET code.
Returns an html image tag pointing to Cloudinary.
Usage:
string tag = cloudinary.Api.UrlImgUp.Format("png").Transform(new CloudinaryDotNet.Transformation().Width(100).Height(100).Crop("fill")).BuildImageTag("sample");
# <img src='http://res.cloudinary.com/cloud_name/image/upload/c_fill,h_100,w_100/sample.png' width='100' height='100'/>
You can find our simple and ready-to-use samples projects, along with documentations in the samples folder. Please consult with the README file, for usage and explanations.
Additional resources are available at:
Contact us at info@cloudinary.com
Or via Twitter: @cloudinary
Released under the MIT license.