.NET integration

Overview

Amend is a Platform–as-a-Service (PaaS) solution hosted on cloud. Amend helps you manage your application’s image resources in the cloud without having to worry about scale and performance. The resources are delivered by high-performance servers through Content Delivery Network (CDN).

Resources are uploaded, managed, and transformed using amend’s easy to use APIs and SDKs. Infrastructure used for these operations is infinitely scalable for handling high load and bursts of traffic.

Quick example

Take a look at the following Amend URL that generates the image below:

Image fit face with width 150 and height 150, radius 20, rotated to 20
150x150 PNG

By calling the above URL Amend is being instructed to transform the uploaded image and create a 150x150px thumbnail using face detection based cropping, round the image's corners, rotate the image by 20 degrees and then deliver resulting image through CDN

.NET Library Features

Amend provides an open source .NET library for further simplifying the integration:

  • Build URLs for image transformation & manipulation.
  • View helper methods for embedding and transforming images.
  • API wrappers: image upload

The library is built for .NET Framework 3.5 and supports higher versions. You can use any .NET language with the library. The library itself is written in C#. Our documentation includes examples in C#.

.NET - Getting started guide

1. Installation

The easiest way to start using Amend's .NET library is to use Visual Studio and NuGet Package Manager. Please see NuGet Documentation for instructions of how to use NuGet packages. Below are the steps required to start a new project using Visual Studio and Amend's .NET library.

  • 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 or above as the target framework.
  • Right click on the project in the Solution Explorer window and click on the menu item 'Manage NuGet packages...'
  • Type Amend in the search box at the upper right corner.
  • When Amend package appears, click on the Install button.
  • After the package is installed, click the Close button.

Use AmendCloud namespace in your code:

For C#:

using AmendCloud;

The library contains powerful helper methods for using directly from views. This documentation provides examples of the integration with Amend's .NET library for the ASP.NET MVC v4.0 framework, for both Razor and ASPX view engines.

Using namespaces in view code:

For Razor/C#:

@using AmendCloud

For ASPX (C#):

<%@ Import Namespace="AmendCloud" %>

2. Configuration

Your Amend Name account parameter is required to create an instance of Amend class, which is the main entry point for using the library. Access Key and Access Secret are further needed to perform secure API calls to Amend (e.g. image uploads). See API, URLs and access identifiers for more details.

Setting the configuration parameters can be done either programmatically using a constructor of the Amend class or globally using an environment variable.

You can find your configuration parameters in the dashboard of our Developer Console.

Here's an example of setting configuration parameters in your .NET application:

For C#:

Amend.setAmendName("my_amend_name");
Amend.setCredentials("my_access_key", "my_access_secret");

3. Upload_images

You can upload images from your server. Uploading is done over HTTP or HTTPS using a secure protocol based on the access_key and access_secret parameters you provide.

The following snippet uploads a local file to Amend:

For C#:

Amend.AmendResponse resp = await new Amend().UploadAsync(System.IO.File.ReadAllBytes(@"c:\mypicture.jpg"));

Each image uploaded to Amend is assigned an unique Image Name and is available for immediate delivery and transformation. The upload method returns an instance of AmendResponse class that contains a set of properties of the uploaded image, including the image URL and Image Name.

Alternatively, you can a specify a the image name. For example:

For C#:

Amend.AmendResponse resp = await new Amend().UploadAsync(System.IO.File.ReadAllBytes(@"c:\mypicture.jpg"), "MyOwnFileName")

The response of content similar to the example below:

{
    ImageName : "baby"
    Width : 450
    Height : 203
    Size : 2100    
    MimeType : "image/jpg"
    Resolution : 300
    CreatedDate : "2016-09-10T13:25:11Z"
    CDNUrl : "http://amend.cloud/test/image/baby"
    SecureCDNUrl : "https://amend.cloud/test/image/baby"
}

4. Display and manipulate images

You can access uploaded images using a URL which is be obtained from an instance of the AmendResponse class after uploading or built using various helper methods of the Url class which could be accessed via an instance of the AmendOptions class through an instance of the AmendOptions class.

You can set image HTML image tag with image name only.

For example, displaying the uploaded image with the baby Image name on myImg id html tag:

AmendOptions amendOptions = new AmendOptions().Transform(new Transform().Width(200).Height(150).Fit(Amend.FIT_FILL));
Amend.Init().Load('baby', amendOptions).Into(myImg);
Image fit fill with width 250 and height 168
200x150 JPG

This is equivalent to:

<img src="http://amend.cloud/test/image/w_200,h_150,fit_fill/baby">

You can easily resize images, perform face detection based cropping, apply effects, overlay text or watermarks.

5. Sample projects

To find additional useful samples and learn how to integrate Amend with your .NET applications, take a look at our Sample Projects. These projects are based on the ASP.NET MVC v4.0 framework and Razor view engine.

Basic Sample: Uploading local images to Amend and generating various transformation URLs.

6. What's next

Sign up for a free account and follow the steps mentioned above to try Amend. Finished all steps? That's just an example of what Amend can offer :

Stay tuned for updates, tips and tutorials: Blog, Twitter, Facebook.