iOS 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:

amend example
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.

iOS Library Features

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

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

iOS - Getting started guide

1. Installation

Amend's iOS integration library is available open-source on git. You can download the latest sources from the following link:

https://github.com/amendcloud/amend_ios_objectiveC/tree/master/AmendLibrary

Drag and Drop following files into your iOS project

Amend.h	
Amend.m	
AmendImageView.h
AmendImageView.m
AmendOption.h
AmendOption.m

2. Configuration

Your amend_name account parameter is required to build image URLs. 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 in each call to a Amend method or globally using an environment variable or the config method.

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

Set the amend_name as AmendName, access_key as AmendKey and access_secret as AmendSecret values under the Amend dictionary of the Info.plist.

ios_plist

3. Upload images

You can upload images from your iOS 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 command uploads a local file to Amend:

 [[[[Amend alloc] init]  initForUpload:self.ivPickerImage.image RequstCode:0 Delegate:self] upload];

you can get image_name return by amend upload api in didReceiveData method, and if some error occured didfailedWithError will called:

-(void)didReceiveData:(NSString *)image_name andReqCode:(int)reqCode{
}
-(void)didfailedWithError:(NSString *)errorMessage andReqCode:(int)reqCode{
}   

4. Display and manipulate images

Adding images to your iOS UIImageView is quite straightforward. Just use the getImage helper method. This method generates the full image resource URL based on the given parameters and internally download image and set to your UIImageView:

For example, displaying the uploaded image with the baby Image Name, while providing an alternate text:

AmendOption *amendOption = [[[AmendOption alloc] init] transform:250 andHeight:168];
[[[Amend alloc] init] getImage:@"baby" setOn:self.ivProcessedImageOutlet];
amend sample
250x168 JPG

Consider a case where you wish to display a small thumbnail of the uploaded image. Simply add the transformation instructions to your call. For example, displaying the 'sample' image transformed to fill a 100x150 rectangle:

AmendOption *amendOption = [[[AmendOption alloc] init] transform:100 andHeight:150 andFit:FIT_FILL];
[[[Amend alloc] init] getImage:@"baby" setOn:self.ivProcessedImageOutlet];
amend sample
100x150 JPG

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

For a full list of supported transformations and their usage, check Image transformations.

5. Sample projects

To find additional useful code samples and learn how to integrate Amend with your iOS applications, take a look at our Sample Projects.

Basic iOS sample: Uploading local images to Amend and generating various transformation URLs, fetch remote image and perform transformations.

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.