Upload images

Amend is a cloud based service to provide hassle free and robust image management solution, covering complete life cycle of image upload, store, administration, transformation, optimization and delivery.

Amend offers very easy to use upload functions in its SDKs to upload image resources to the cloud and once uploaded you can perform various image transformations without writing long lines of code.

Uploaded images are available to be used for transformations like compression, resize, rotate etc. and transformed images can be accessed from web/mobile applications. (Check image transformation section for detailed feature list).

Amend’s image management service offers following operations:

Uploading images to the cloud

Uploading is done over HTTP or HTTPS using a secure protocol based on your account's amend_name, access_key and access_secret parameters. When using Amend's SDKs, the 3 security parameters are generally configured globally, but they can be provided with each call instead.

Uploading images to amend can be done easily using our SDKs :

The Amend upload function performs validated API call for upload over HTTP/HTTPS while uploading the image file:

.NET:
Amend.UploadAsync(file);
PHP:
Amend::upload($file);
jQuery:
Amend.upload(file, callback);
Android:
Amend.with(context).upload(file, callback);
iOS:
[[[[Amend alloc] init]  initForUpload:self.ivPickerImage.image RequstCode:0 Delegate:self] upload];

Upload operation is performed synchronously and once completed, the uploaded image is immediately made available for transformation and delivery.

Image Name - the image identifier

Every uploaded image on Amend is uniquely identified with the parameter Image Name which is unique against your amend name. This string type parameter (Image Name) is used as reference to form dynamic delivery URLs, these URLs also have transformation parameters.

If you don't pass Image Name parameter in API call for uploading image, you will get a random image Name which is assigned in response to the call. Random image_name is having a set pattern and contains your amend name and a random numeric value that will form a name like this: test_12812. So if your amend name is ‘test’, the URL for accessing this image would be:

http://amend.cloud/test/image/test_12812

It is recommended that you should assign image_name parameter while uploading the image, this will be helpful to make your delivery URLs readable. For example:

.NET
Amend.upload(sampleImage, "sample_id");
PHP:
Amend::upload($sampleImg,"sample_id");
jQuery:
Amend.upload($sampleImg, "sample_id");
Android:
Amend.with(context).upload(imageFile,"sample_id");
iOS:
[[[[Amend alloc] init] initForUpload:self.ivPickerImage.image RequstCode:0 Delegate:self] uploadWithImageName:@"Name_of_image"];

Data upload options

Amend offers you ease in uploading images which are already on web by allowing you to fetch and store these images in amend with a single line of code. You just need to specify their URLs instead of uploading the image. In this case, this helps in faster migration of existing images. For example:

.NET:
Amend.upload("http://www.example.com/sample.jpg");
PHP:
Amend::upload("http://www.example.com/sample.jpg");
jQuery:
Amend.upload("http://www.example.com/sample.jpg")
Android:
Amend.with(context).upload("http://www.example.com/sample.jpg");

You can upload an image by specifying the Data URI in Base 64 encoding of an image file (no larger than 6 MB). For example:

.NET:
Amend.upload("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")
PHP:
Amend::upload("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");
jQuery:
amend.uploader.upload("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==")
Android:
Amend.with(contextt).upload("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==");

Upload response

An upload API call returns a response with following parameters: HTTP/HTTPS URLs referring to uploaded image, Image Name, dimensions, image mimetype. Here’s an example of the JSON response received:

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

For more information on uploading images from server side code for specific frameworks, see .NET, PHP, jQuery, iOS or Android .

Image Management

Images can be managed through Amend's API or Media Libraryin your developer console, following actions on an uploaded image file:

  • Delete the image.
  • Rename the image by changing its Image Name.

Deleting images

Deleted images are immediately deleted permanently from your amend cloud storage with the destroy function. However, images accessed by your website/mobile applications might still be available through cached copies on the CDN

Note that it usually takes a few minutes (although it might take up to an hour) for the invalidation to fully propagate through the CDN.

For example, deleting an image with the Image Name of "sample":

.Net:
Amend.Destroy("sample")
PHP:
Amend::destroy('sample');
jQuery:
Amend.destroy('sample', function (error, result) {console.log(result) });
Android:
Amend.with(context).destroy('sample', callback);

Renaming images

Rename operation is immediately performed and starts reflecting change from very next call, the rename function is used for this purpose. Any existing URLs of renamed images will no longer be valid once rename operation is carried.

Note: It takes some time (from couple of minutes to an hour) to fully propagate the change through the CDN.

For example, renaming an image with the Image Name of old_name to new_name:

.Net:
Amend.Rename("oldName", "newName")
PHP:
Amend::rename('old_name', 'new_name');
jQuery:
Amend.rename('old_name', 'new_name', function(error, result) { console.log(result) })
Android:
Amend.with(context).rename("oldName", "newName", callback);