App42 Cloud API

iOS cloud SDK

Image Processor

The ImageProcessor service is a Image utility service on the Cloud. Developers can upload files on the cloud and perform various Image Manipulation operations on the Uploaded Images e.g. resize, scale, thumbnail, crop etc. It is especially useful for Mobile Apps when they dont want to store Images locally and dont want to perform processor intensive operations. It is also useful for web applications who want to perform complex Image Operations

In order to use the various functions available under a particular API, a developer will have to create an instance of ServiceAPI by passing the apiKey and the secretKey which has been received while creating an app.

ServiceAPI *serviceAPIObj = [[ServiceAPI alloc]init];
serviceAPIObj.apiKey = @"<API_KEY>";
serviceAPIObj.secretKey = @"<SECRET_KEY>";

After initialization, developer needs to call the buildXXXService method on ServiceAPI instance to get the instance of the particular API that you wish to build. For example, To build an instance of ImageProcessorService, buildImageProcessorService() method needs to be called.

	ImageProcessorService imageProcessorService = api.buildImageProcessorService();	

Once the API instance has been retrieved, You are ready to use the functions available for that particular API.

The methods available under a particular API will return the domain object (like Image in this case) as a response which will have the accessor / mutator to access the available properties for that object. You can get the response in the form of JSON as well. We have provided the JSON response with every function detail which can be retrieved by calling the toString() on the returned object.

NSString *name = @"Resize01";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
ImageProcesor *image = [imageProcesorService resize:name imagePath:imagePath width:width height:height];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */ 

The functions available under ImageProcessor API can throw some exceptions in abnormal conditions. Example of the same has been given below.

E.g. If App developer is resizing the image file and storing it with the name which already exist in the database, the function will throw the App42Exception (as shown below) with message as "Bad Request" and the appErrorCode as "3200" and the details as "The request parameters are invalid. Image with the name '<name>' already exists".

NSString *name = @"Resize01";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
@try{
	ImageProcesor *image = [imageProcesorService resize:name imagePath:imagePath width:width height:height];  /* returns the Image object. */ 
} @catch(App42Exception *ex) {
	int appErrorCode = ex.appErrorCode;
	int httpErrorCode = ex.httpErrorCode;
	if(appErrorCode == 3200)
	{
		// Handle here for Bad Request (The request parameters are invalid. Image with the name '<name>' already exists.)
	}	
	else if(appErrorCode == 1401)
	{
		// handle here for Client is not authorized
	}
	else if(appErrorCode == 1500)
	{
		// handle here for Internal Server Error
	}	
	NSString *jsonText = ex.reason; /* returns the Exception text in JSON format. (as shown below)*/
}  
	{
		"app42Fault": {
			"httpErrorCode": 400,
			"appErrorCode": 3200,
			"message": "Bad Request",
			"details": "The Request parameters are invalid. Image with the name 'Resize01' already Exists"
		}
	}							

Below are the HTTP Error Codes and their description, the function under the Image Processor API can throw.

/*
1400 - BAD REQUEST - The Request parameters are invalid
1401 - UNAUTHORIZED - Client is not authorized
1500 - INTERNAL SERVER ERROR - Internal Server Error. Please try again	
*/						

Below are the Application Error Codes and their description, the function under the Image Processor API can throw.

/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/			

Various functions available under ImageProcessor API has been explained below.

-(Image*)resize:(NSString*)name imagePath:(NSString*)imagePath width:(int)width height:(int)height

Resize image. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided.

Parameters:

name - Name of the image to resize
imagePath - Path of the local file to resize
width - Width of the image to resize
height - Height of the image to resize

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 	        
For more details click Exception
NSString *name = @"Resize01";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
ImageProcesor *image = [imageProcesorService resize:name imagePath:imagePath width:width height:height];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Resize01",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/d2tj2vy",
                "convertedImageTinyUrl": "http://tinyurl.com/c3vknau",
                "width": 234,
                "height": 1000
            }
        }
    }
}
-(Image*)thumbnail:(NSString*)name imagePath:(NSString*)imagePath width:(int)width height:(int)height

Creates a thumbnail of the image. There is a difference between thumbnail and resize The thumbnail operation is optimized for speed, it removes information of the image which is not necessary for a thumbnail e.g hearder information. Returns the original image url and converted image url. Images are stored on the cloud and can be accessed through the urls Resizing is done based on the width and height provided.

Parameters:

name - Name of the image file for which thumbnail has to be created
imagePath - Path of the local file whose thumbnail has to be created
width - Width of the image for thumbnail
height - Height of the image for thumbnail

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		       
For more details click Exception
NSString *name = @"Thumbnail1";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
ImageProcesor *image = [imageProcesorService thumbnail:name imagePath:imagePath width:width height:height];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Thumbnail",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/clyf8mz",
                "convertedImageTinyUrl": "http://tinyurl.com/buthakc",
                "width": 234,
                "height": 1000
            }
        }
    }
}
-(Image*)scale:(NSString*)name imagePath:(NSString*)imagePath width:(int)width height:(int)height

Scales the image based on width and height. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to scale
imagePath - Path of the local file to scale
width - Width of the image to scale
height - Height of the image to scale

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 	       
For more details click Exception
NSString *name = @"Scale01";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
ImageProcesor *image = [imageProcesorService scale:name imagePath:imagePath width:width height:height];  /* returns the Image object. */  
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Scale01",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/c35yhp2",
                "convertedImageTinyUrl": "http://tinyurl.com/blbw65b",
                "width": 234,
                "height": 1000
            }
        }
    }
}
-( Image*)crop:(NSString*)name imagePath:(NSString*)imagePath width:(int)width height:(int)height x:(int)x y:(int)y

Crops image based on width, height and x, y coordinates. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to crop
imagePath - Path of the local file to crop
width - Width of the image to crop
height - Height of the image to crop
x - Coordinate X
y - Coordinate Y

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		    
For more details click Exception
NSString *name = @"Crop";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
int x = 34;
int y = 32;
ImageProcesor *image = [imageProcesorService crop:name imagePath:imagePath width:width height:height x:x y:y];  /* returns the Image object. */
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSLog(@"x = %i",image.x);
NSLog(@"y = %i",image.y);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Crop",
                "action": "CROP",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-crop.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/cy9ydr2",
                "convertedImageTinyUrl": "http://tinyurl.com/cs9axzk",
                "width": 21,
                "height": 23,
                "x": 34,
                "y": 32
            }
        }
    }
}
-(Image*)resizeByPercentage:(NSString*)name imagePath:(NSString*)imagePath percentage:(double)percentage

Resize image by Percentage. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to resize
imagePath - Path of the local file to resize
percentage - Percentage to which image has to be resized

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		    
For more details click Exception
NSString *name = @"ResizeByPercentage02";
NSString *imagePath = @"Local file path";
double percentage = 10.90;
ImageProcesor *image = [imageProcesorService resizeByPercentage:name imagePath:imagePath percentage:percentage];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"percentage is = %@,image.percentage);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ResizeByPercentageTue Jul 24 13:20:55 IST 2012.jpg",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/c5zo79m",
                "convertedImageTinyUrl": "http://tinyurl.com/ck4o4s5",
                "percentage": "10.9"
            }
        }
    }
}
-(Image*)thumbnailByPercentage:(NSString*)name imagePath:(NSString*)imagePath percentage:(double)percentage

Creates a thumbnail of the image by Percentage. There is a difference between thumbnail and resize. The thumbnail operation is optimized for speed removes information of the image which is not necessary for a thumbnail to reduce size e.g hearder information. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls. Resizing is done based on the width and height provided.

Parameters:

name - Name of the image file for which thumbnail has to be created
imagePath - Path of the local file whose thumbnail has to be created
percentage - Percentage for thumbnail

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists. 
*/	        
For more details click Exception
NSString *name = @"ThumbnailByPercentage";
NSString *imagePath = @"Local file path";
double percentage = 10.90;
ImageProcesor *image = [imageProcesorService thumbnailByPercentage:name imagePath:imagePath percentage:percentage];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"percentage is = %@,image.percentage);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ThumbnailByPercentage",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/cgpqlja",
                "convertedImageTinyUrl": "http://tinyurl.com/cspufmt",
                "percentage": "10.7"
            }
        }
    }
}
-(Image*)scaleByPercentage:(NSString*)name imagePath:(NSString*)imagePath percentage:(double)percentage

Scales the image by Percentage. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided.

Parameters:

name - Name of the image file to scale
imagePath - Path of the local file to scale
percentage - Percentage to which image has to be scaled

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

This method throws following exception.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists. 
*/		       
For more details click Exception
NSString *name = @"ScaleByPercentage";
NSString *imagePath = @"Local file path";
double percentage = 10.90;
ImageProcesor *image = [imageProcesorService scaleByPercentage:name imagePath:imagePath percentage:percentage];  /* returns the Image object. */  
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"percentage is = %@,image.percentage);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ScaleByPercentage",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/csyv2f8",
                "convertedImageTinyUrl": "http://tinyurl.com/cwbdj73",
                "percentage": "10.9"
            }
        }
    }
}
-(Image*)resize:(NSString*)name imageData:(NSData*)imageData width:(int)width height:(int)height

Resize image. Returns the original image url and converted image url. Images are stored on the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to resize
imageData - data of the file to resize
width - Width of the image to resize
height - Height of the image to resize

Returns:

Image object containing urls for the original and converted images

Response: Image Object

For more details click Exception
NSString *name = @"Resize";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService resize:name imageData:imageData width:width height:height];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Resize.jpg",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/cgmaetq",
                "convertedImageTinyUrl": "http://tinyurl.com/cnvqu6y",
                "width": 234,
                "height": 1000
            }
        }
    }
}
-(Image*)thumbnail:(NSString*)name imageData:(NSData*)imageData width:(int)width height:(int)height

Creates a thumbnail of the image. There is a difference between thumbnail and resize The thumbnail operation is optimized for speed, it removes information of the image which is not necessary for a thumbnail e.g hearder information. Returns the original image url and converted image url. Images are stored on the cloud and can be accessed through the urls Resizing is done based on the width and height provided.

Parameters:

name - Name of the image file for which thumbnail has to be created
imageData - Data of the local file whose thumbnail has to be created
width - Width of the image for thumbnail
height - Height of the image for thumbnail

Returns:

Image object containing urls for the original and converted images

Response: Image Object

NSString *name = @"Thumbnail1";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService thumbnail:name imagePath:imagePath width:width height:height];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Thumbnail1",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "width": 234,
                "height": 1000
            }
        }
    }
}
-(Image*)scale:(NSString*)name imageData:(NSData*)imageData width:(int)width height:(int)height

Scales the image based on width and height. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to scale
imageData - Data of the local file to scale
width - Width of the image to scale
height - Height of the image to scale

Returns:

Image object containing urls for the original and converted images

Response: Image Object

NSString *name = @"Scale01";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService scale:name imagePath:imagePath width:width height:height];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Scale01",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/cvlb9tg",
                "convertedImageTinyUrl": "http://tinyurl.com/dy77dbd",
                "width": 234,
                "height": 1000
            }
        }
    }
}
-(Image*)crop:(NSString*)name imageData:(NSData*)imageData width:(int)width height:(int)height x:(int)x y:(int)y

Crops image based on width, height and x, y coordinates. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to crop
imageData - Data of the local file to scale
width - Width of the image to crop
height - Height of the image to crop
x - Coordinate X
y - Coordinate Y

Returns:

Image object containing urls for the original and converted images

Response: Image Object

For more details click Exception
NSString *name = @"Crop";
NSString *imagePath = @"Local file path";
int width = 234;
int height = 1000;	
int x = 34;
int y = 32;
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService crop:name imagePath:imagePath width:width height:height x:x y:y];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"width = %i",image.width);
NSLog(@"height = %i",image.height);
NSLog(@"x = %i",image.x);
NSLog(@"y = %i",image.y);	
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Crop",
                "action": "CROP",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-crop.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/clyqtau",
                "convertedImageTinyUrl": "http://tinyurl.com/crysqcn",
                "width": 234,
                "height": 1000,
                "x": 34,
                "y": 32
            }
        }
    }
}
-(Image*)resizeByPercentage:(NSString*)name imageData:(NSData*)imageData percentage:(double)percentage

Resize image by Percentage. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided

Parameters:

name - Name of the image to resize
imageData - Data of the local file to resize
percentage - Percentage to which image has to be resized

Returns:

Image object containing urls for the original and converted images

Response: Image Object

For more details click Exception
NSString *name = @"ResizeByPercentage02";
NSString *imagePath = @"Local file path";
double percentage = 10.90;
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService scaleByPercentage:name imageData:imageData percentage:percentage];  /* returns the Image object. */
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"percentage is = %f",image.percentage);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ResizeByPercentage02",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/dxu7skv",
                "convertedImageTinyUrl": "http://tinyurl.com/bnkcvxw",
                "percentage": "10.9"
            }
        }
    }
}
-(Image*)thumbnailByPercentage:(NSString*)name imageData:(NSData*)imageData percentage:(double)percentage

Creates a thumbnail of the image by Percentage. There is a difference between thumbnail and resize. The thumbnail operation is optimized for speed removes information of the image which is not necessary for a thumbnail to reduce size e.g hearder information. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls. Resizing is done based on the width and height provided.

Parameters:

name - Name of the image file for which thumbnail has to be created
imageData - Data of the local file to resize
percentage - Percentage for thumbnail

Returns:

Image object containing urls for the original and converted images

Response: Image Object

For more details click Exception
NSString *name = @"ThumbnailByPercentage";
NSString *imagePath = @"Local file path";
double percentage = 10.90;
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService thumbnailByPercentage:name imageData:imageData percentage:percentage];  /* returns the Image object. */ 
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"percentage is = %f",image.percentage);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ThumbnailByPercentage",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/boalf97",
                "convertedImageTinyUrl": "http://tinyurl.com/bovsocv",
                "percentage": "10.7"
            }
        }
    }
}
-(Image*)scaleByPercentage:(NSString*)name imageData:(NSData*)imageData percentage:(double)percentage

Scales the image by Percentage. Returns the original image url and converted image url. Images are stored in the cloud and can be accessed through the urls Resizing is done based on the width and height provided.

Parameters:

name - Name of the image file to scale
imageData - Data of the local file to resize
percentage - Percentage to which image has to be scaled

Returns:

Image object containing urls for the original and converted images

Response: Image Object

For more details click Exception
NSString *name = @"ScaleByPercentage";
NSString *imagePath = @"Local file path";
double percentage = 10.90;
NSData *imageData = [NSData dataWithContentsOfFile:[NSURL fileURLWithPath:imagePath]];
ImageProcesor *image = [imageProcesorService scaleByPercentage:name imagePath:imagePath percentage:percentage];  /* returns the Image object. */  
NSLog(@"imageName is = %@",image.name);
NSLog(@"originalImage is  = %@",image.originalImage);
NSLog(@"convertedImage is = %@",image.convertedImage);
NSLog(@"percentage is = %f",image.percentage);
NSString *jsonResponse = [image toString]; /* returns the response in JSON format. */
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ScaleByPercentage",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/brmnwyd",
                "convertedImageTinyUrl": "http://tinyurl.com/cxyzjwf",
                "percentage": "10.9"
            }
        }
    }
}