App42 Cloud API

Java and Groovy Cloud SDK

Image Processor

The ImageProcessor service is an 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 api = new ServiceAPI("<API_KEY>","<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.

String name = "Resize01";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;	

Image image = imageProcessorService.resize(imageName,imagePath, width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("width is " + image.getWidth());
System.out.println("height is " + image.getHeight());
String 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".

String name = "Resize01';
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;	

try
{
	Image image = imageProcessorService.resize(imageName,imagePath, width,height);
}
catch(App42Exception ex) 
{
	int appErrorCode = ex.getAppErrorCode();
	int httpErrorCode = ex.getHttpErrorCode();
	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
	}	
	String jsonText = ex.getMessage(); /* 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.

public Image resize(String name, String imagePath, Integer width, Integer height) throws App42Exception

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:

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 	        
For more details click Exception
String name = "Resize01';
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;						

Image image = imageProcessorService.resize(name,imagePath,width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("width is " + image.getWidth());
System.out.println("height is " + image.getHeight());			
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/     
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Resize01",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 234,
                "height": 1000
            }
        }
    }
}
public Image thumbnail(String name, String imagePath, Integer width, Integer height) throws App42Exception

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

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		       
For more details click Exception
String name = "Thumbnail1";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;					

Image image = imageProcessorService.thumbnail(name,imagePath,width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("width is " + image.getWidth());
System.out.println("height is " + image.getHeight());			
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/    
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Thumbnail",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 234,
                "height": 1000
            }
        }
    }
}
public Image scale(String name, String imagePath, Integer width, Integer height) throws App42Exception

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:

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 	       
For more details click Exception
String name = "Scale01";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;
						
Image image = imageProcessorService.scale(name,imagePath,width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("width is " + image.getWidth());
System.out.println("height is " + image.getHeight());				
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/    
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Scale01",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 234,
                "height": 1000
            }
        }
    }
}
public Image crop(String name, String imagePath, Integer width, Integer height, Integer x, Integer y) throws App42Exception

Crops the 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:

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		    
For more details click Exception
String name = "Crop";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;
Integer x = 34 ;
Integer y = 32 ;
						
Image image = imageProcessorService.crop(name,imagePath,width,height,x,y);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("width is " + image.getWidth());
System.out.println("height is " + image.getHeight());
System.out.println("x is " + image.getX());
System.out.println("y is " + image.getY());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Crop",
                "action": "CROP",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-crop.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 21,
                "height": 23,
                "x": 34,
                "y": 32
            }
        }
    }
}
public Image convertFormat(String name, String imagePath, String formatToConvert) throws App42Exception

Converts the format of the image. Returns the original image url and converted image url. Images are stored on the cloud and can be accessed through the urls Conversion is done based on the formatToConvert provided

Parameters:

name - Name of the image to resize
imagePath - Path of the local file to resize
formatToConvert - To which file needs to be converted

Returns:

Image object containing urls for the original and converted images

Response: Image Object

Exception:

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		    
For more details click Exception
String name = "Convert";
String imagePath = "Local file path";
String formatToConvert = "new type in which file has to be converted";
						
Image image = imageProcessorService.convertFormat(name,imagePath,formatToConvert); /* returns the Image object. */
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ResizeTue Oct 09 14:23:54 IST 2012",
                "action": "ConvertFormat",
                "originalImage": "http://XXXXX.jpg",
                "convertedImage": "http://XXXXX-convert.png",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX"
            }
        }
    }
}    
public Image resizeByPercentage(String name, String imagePath, Double percentage) throws App42Exception

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:

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists.
*/ 		    
For more details click Exception
String name = "ResizeByPercentage02";
String imagePath = "Local file path";
Double percentage = 10.90;						

Image image = imageProcessorService.resizeByPercentage(name,imagePath,percentage);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("percentage is " + image.getPercentage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/     
{
    "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/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "percentage": "10.9"
            }
        }
    }
}
public Image thumbnailByPercentage(String name, String imagePath, Double percentage) throws App42Exception

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

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists. 
*/	        
For more details click Exception
String name = "ThumbnailByPercentage";
String imagePath = "Local file path";
Double percentage = 10.70;	

Image image = imageProcessorService.thumbnailByPercentage(name,imagePath,percentage);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("percentage is " + image.getPercentage());		
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/     
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ThumbnailByPercentage",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "percentage": "10.7"
            }
        }
    }
}
public Image scaleByPercentage(String name, String imagePath, Double percentage) throws App42Exception

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:

The method throws the following exception with the error code.
/*
3200 - BAD REQUEST - The request parameters are invalid. Image with the name '<name>' already exists. 
*/		       
For more details click Exception
String name = "ScaleByPercentage";
String imagePath = "Local file path";
Double percentage = 10.90;	

Image image = imageProcessorService.scaleByPercentage(name,imagePath,percentage);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("percentage is " + image.getPercentage()); 			
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/  
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ScaleByPercentage",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "percentage": "10.9"
            }
        }
    }
}
public Image resize(String name, InputStream inputStream, Integer width, Integer height) throws App42Exception

Resize image via Stream. 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
inputStream - InputStream of the local file to resize
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

For more details click Exception
String name = "Resize";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;
FileInputStream fileInputStream = null;

try
{
	fileInputStream = new FileInputStream(imagePath);
} 
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}					
Image image = imageProcessorService.resize(name,fileInputStream,width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/        
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Resize.jpg",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 234,
                "height": 1000
            }
        }
    }
}
public Image thumbnail(String name, InputStream inputStream, Integer width, Integer height) throws App42Exception

Creates a thumbnail of the image via Stream. 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 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
inputStream - InputStream 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

For more details click Exception
String name = "Thumbnail1";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;
FileInputStream fileInputStream = null;

try
{
	fileInputStream = new FileInputStream(imagePath);
}
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}					
Image image = imageProcessorService.thumbnail(name,fileInputStream,width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/      
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Thumbnail1",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "width": 234,
                "height": 1000
            }
        }
    }
}
public Image scale(String name, InputStream inputStream, Integer width, Integer height) throws App42Exception

Scales the image based on width and height via Stream. 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
inputStream - 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

For more details click Exception
String name = "Scale01";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;
FileInputStream fileInputStream = null;

try 
{
	fileInputStream = new FileInputStream(imagePath);
}
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}				
Image image = imageProcessorService.scale(name,fileInputStream,width,height);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/      
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Scale01",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 234,
                "height": 1000
            }
        }
    }
}
public Image crop(String name, InputStream inputStream, Integer width, Integer height, Integer x, Integer y) throws App42Exception

Crops image based on width, height and x, y coordinates via Stream. 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
inputStream - inputStream InputStream 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
String name = "Crop";
String imagePath = "Local file path";
Integer width = 234;
Integer height = 1000;
Integer x = 34 ;
Integer y = 32 ;
FileInputStream fileInputStream = null;

try 
{
	fileInputStream = new FileInputStream(imagePath);
} 
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}				
Image image = imageProcessorService.crop(name,fileInputStream,width,height,x,y);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/       
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Crop",
                "action": "CROP",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-crop.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "width": 234,
                "height": 1000,
                "x": 34,
                "y": 32
            }
        }
    }
}
public Image resizeByPercentage(String name, InputStream inputStream, Double percentage) throws App42Exception

Resize the image by Percentage via Stream. 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
inputStream - InputStream 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
String name = "ResizeByPercentage02";
String imagePath = "Local file path";
Double percentage = 10.9;						
FileInputStream fileInputStream = null;

try 
{
	fileInputStream = new FileInputStream(imagePath);
} 
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}				
Image image = imageProcessorService.resizeByPercentage(name,fileInputStream,percentage);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("percentage is " + image.getPercentage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/       
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ResizeByPercentage02",
                "action": "RESIZE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-resize.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "percentage": "10.9"
            }
        }
    }
}
public Image thumbnailByPercentage(String name, InputStream inputStream, Double percentage) throws App42Exception

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 header 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
inputStream - InputStream 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
String name = "ThumbnailByPercentage";
String imagePath = "Local file path";
Double percentage = 10.70;						
FileInputStream fileInputStream = null;

try 
{
	fileInputStream = new FileInputStream(imagePath);
}
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}					
Image image = imageProcessorService.thumbnailByPercentage(name,fileInputStream,percentage);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("percentage is " + image.getPercentage());		
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ThumbnailByPercentage",
                "action": "THUMBNAIL",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-thumbnail.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "percentage": "10.7"
            }
        }
    }
}
public Image scaleByPercentage(String name, InputStream inputStream, Double percentage) throws App42Exception

Scales the image by Percentage via Stream. 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
inputStream - InputStream 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
String name = "ScaleByPercentage";
String imagePath = "Local file path";
Double percentage = 10.90;						
FileInputStream fileInputStream = null;

try 
{
	fileInputStream = new FileInputStream(imagePath);
}
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}					
Image image = imageProcessorService.scaleByPercentage(name,fileInputStream,percentage);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
System.out.println("percentage is " + image.getPercentage()); 			
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/    
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "ScaleByPercentage",
                "action": "SCALE",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-scale.jpg",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX",
                "percentage": "10.9"
            }
        }
    }
}
public Image convertFormat(String name, InputStream inputStream, String formatToConvert) throws App42Exception

Converts the format of the image. Returns the original image url and converted image url. Images are stored on the cloud and can be accessed through the urls Conversion is done based on the formatToConvert provided

Parameters:

name - Name of the image to convert
inputStream - InputStream of the local file to convert
formatToConvert - to which file needs to be converted

Returns:

Image object containing urls for the original and converted images

Response: Image Object

For more details click Exception
String name = "ConvertFormat";
String imagePath = "Local file path";
String formatToConvert = "new type in which file has to be converted";						
FileInputStream fileInputStream = null;

try 
{
	fileInputStream = new FileInputStream(imagePath);
}
catch (FileNotFoundException e) 
{
	e.printStackTrace();
}					
Image image = imageProcessorService.convertFormat(name, fileInputStream, formatToConvert);  /* returns the Image object. */ 
System.out.println("imageName is " + image.getName());
System.out.println("originalImage is " + image.getOriginalImage());
System.out.println("convertedImage is " + image.getConvertedImage());
String jsonResponse = image.toString(); /* returns the response in JSON format. (as shown below)*/
{
    "app42": {
        "response": {
            "success": true,
            "image": {
                "name": "Convert1349772926567.jpg",
                "action": "ConvertFormat",
                "originalImage": "http://XXXX.jpg",
                "convertedImage": "http://XXXX-convert.png",
                "originalImageTinyUrl": "http://tinyurl.com/XXXX",
                "convertedImageTinyUrl": "http://tinyurl.com/XXXX"
            }
        }
    }
}