Skip to content

Instantly share code, notes, and snippets.

@aspose-imaging
Last active March 9, 2017 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aspose-imaging/d93584cb0b729768da5832dac697821a to your computer and use it in GitHub Desktop.
Save aspose-imaging/d93584cb0b729768da5832dac697821a to your computer and use it in GitHub Desktop.
Aspose_Imaging_Cloud_Python
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
fileName = "aspose"
name = fileName + ".jpg"
format = "png"
try:
#invoke Aspose.Imaging Cloud SDK API to perform format change operation without using cloud storage
response = imagingApi.PostImageSaveAs(format, file =data_folder + name )
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + fileName + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "TestDemo.tif"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update TIFF file and convert it to Fax compatible format
response = imagingApi.GetTiffToFax(name)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import common
input_file = "sample1.tiff"
input_path = common.get_path(__file__, input_file)
output_file = "output.tiff"
output_path = common.get_path(__file__, output_file)
common.StorageApi.PutCreate(input_file, input_path)
# invoke Aspose.Imaging Cloud SDK API to perform format change operation without using cloud storage
response = common.imagingApi.GetTiffToFax(input_file)
if response.Status == 'OK':
# download image from API response
with open(output_path, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "TestDemo.tif"
frameId = 0
newWidth = 200
newHeight = 200
x = 20
y = 20
rectWidth = 100
rectHeight = 100
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to extract and crop a frame from a Tiff image
response = imagingApi.GetImageFrame(name, frameId, newWidth=newWidth, newHeight=newHeight, x=x, y=y, rectWidth=rectWidth, rectHeight=rectHeight)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
fileName = "aspose"
name = fileName + ".jpg"
format = "png"
x = 30
y = 40
width = 100
height = 100
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to perform crop operation on an image
response = imagingApi.GetCropImage(name, format, x, y, width, height)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + fileName + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample-multi.tif"
frameId = 1
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to extract only one frame from a Tiff image
response = imagingApi.GetImageFrame(name, frameId)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
#ExStart: 1
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "demo.tif"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to get image properties
response = imagingApi.GetImageProperties(name)
if response.Status == 'OK':
tiffProperties = response.TiffProperties
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
#ExEnd: 1
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample-multi.tif"
frameId = 1
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to retrieve properties of a specific Tiff Frame
response = imagingApi.GetImageFrameProperties(name, frameId)
if response.Status == 'OK':
tiffProperties = response.TiffProperties
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample-multi.tif"
frameId = 1
rotateFlipMethod = "rotate90flipnone"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to extract and RotateFlip a frame and save with unmodified frames in a Tiff image
response = imagingApi.GetImageFrame(name, frameId, rotateFlipMethod=rotateFlipMethod)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "TestDemo.tif"
appendFile = "TestDemo.tif"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
response = storageApi.PutCreate(appendFile, data_folder + appendFile)
#invoke Aspose.Imaging Cloud SDK API to merge TIFF files
response = imagingApi.PostTiffAppend(name, appendFile=appendFile)
if response.Status == 'OK':
#download updated image from cloud storage
response = storageApi.GetDownload(Path=name)
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
fileName = "TestDemo"
name = fileName + ".tif"
format = "png"
x = 96
y = 96
newWidth = 300
newHeight = 300
rectWidth = 200
rectHeight = 200
rotateFlipMethod = ""
try:
#invoke Aspose.Imaging Cloud SDK API to perform crop, resize, rotation & export operations on an image in a single call
response = imagingApi.PostImageSaveAs_ImagingApi_0(format, newWidth, newHeight, x, y, rectWidth, rectHeight, rotateFlipMethod, file= data_folder + name)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + fileName + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "TestDemo.tif"
frameId = 0
newWidth = 300
newHeight = 300
x = 96
y = 96
rectWidth = 200
rectHeight = 200
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to extract and resize one frame from a Tiff image
response = imagingApi.GetImageFrame(name, frameId, newWidth=newWidth, newHeight=newHeight, x=x, y=y, rectWidth=rectWidth, rectHeight=rectHeight)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import common
input_file = "sample1.png"
input_path = common.get_path(__file__, input_file)
output_file = "output.jpg"
output_path = common.get_path(__file__, output_file)
format = "jpg"
newWidth = 200
newHeight = 200
# invoke Aspose.Imaging Cloud SDK API to perform format change operation without using cloud storage
response = common.imagingApi.PostChangeImageScale(format, newWidth, newHeight, file=input_path)
if response.Status == 'OK':
# download image from API response
with open(output_path, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
fileName = "aspose_imaging_for_cloud"
name = fileName + ".png"
format = "jpg"
newWidth = 200
newHeight = 200
try:
#invoke Aspose.Imaging Cloud SDK API to perform re-size operation without using cloud storage
response = imagingApi.PostChangeImageScale(format, newWidth, newHeight, file = data_folder + name)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + fileName + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
fileName = "aspose_imaging_for_cloud"
name = fileName + ".png"
format = "jpg"
newWidth = 200
newHeight = 200
try:
#invoke Aspose.Imaging Cloud SDK API to perform re-size with format conversion operation without using cloud storage
response = imagingApi.PostChangeImageScale(format, newWidth, newHeight, file = data_folder + name)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + fileName + "." + format
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "TestDemo.tif"
frameId = 0
rotateFlipMethod = "rotate270flipnone"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to extract and RotateFlip a frame from a Tiff image
response = imagingApi.GetImageFrame(name, frameId, rotateFlipMethod=rotateFlipMethod)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
fileName = "aspose"
name = fileName + ".jpg"
format = "png"
method = "Rotate180FlipX"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to perform RotateFlip operation on an image
response = imagingApi.GetImageRotateFlip(name, format, method)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample.bmp"
bitsPerPixel = 24
horizontalResolution = 300
verticalResolution = 300
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update BMP specific properties
response = imagingApi.GetImageBmp(name, bitsPerPixel, horizontalResolution, verticalResolution)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample.bmp"
bitsPerPixel = 24
horizontalResolution = 300
verticalResolution = 300
try:
#invoke Aspose.Imaging Cloud SDK API to update BMP specific properties without using cloud storage
response = imagingApi.PostImageBmp(bitsPerPixel, horizontalResolution, verticalResolution, file=data_folder + name)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample.gif"
backgroundColorIndex = 255
colorResolution = 7
pixelAspectRatio = 10
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update GIF specific properties
response = imagingApi.GetImageGif(name, backgroundColorIndex=backgroundColorIndex, colorResolution=colorResolution, pixelAspectRatio=pixelAspectRatio)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample.gif"
backgroundColorIndex = 255
colorResolution = 7
pixelAspectRatio = 10
try:
#invoke Aspose.Imaging Cloud SDK API to update GIF specific properties without using cloud storage
response = imagingApi.PostImageGif(file = data_folder + name, backgroundColorIndex=backgroundColorIndex, colorResolution=colorResolution, pixelAspectRatio=pixelAspectRatio)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "aspose.jpg"
quality = 100
compressionType = "progressive"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update JPG specific properties
response = imagingApi.GetImageJpg(name, quality=quality, compressionType=compressionType)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "aspose.jpg"
quality = 100
compressionType = "progressive"
try:
#invoke Aspose.Imaging Cloud SDK API to update JPG specific properties without using cloud storage
response = imagingApi.PostImageJpg(file=data_folder + name)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "aspose_imaging_for_cloud.png"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update PNG specific properties
response = imagingApi.GetImagePng(name, fromScratch=False)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "aspose_imaging_for_cloud.png"
try:
#invoke Aspose.Imaging Cloud SDK API to update PNG specific properties without using cloud storage
response = imagingApi.PostImagePng(file=data_folder + name, fromScratch=False)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample.psd"
channelsCount = 3
compressionMethod = "rle"
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update PSD specific properties
response = imagingApi.GetImagePsd(name, channelsCount=channelsCount, compressionMethod=compressionMethod)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "sample.psd"
channelsCount = 3
compressionMethod = "rle"
try:
#invoke Aspose.Imaging Cloud SDK API to update PSD specific properties without using cloud storage
response = imagingApi.PostImagePsd(file=data_folder + name, channelsCount=channelsCount, compressionMethod=compressionMethod)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "demo.tif"
compression = "ccittfax3"
resolutionUnit = "inch"
bitDepth = 1
try:
#upload file to aspose cloud storage
response = storageApi.PutCreate(name, data_folder + name)
#invoke Aspose.Imaging Cloud SDK API to update Tiff specific properties
response = imagingApi.PostProcessTiff(file=data_folder + name, compression=compression, resolutionUnit=resolutionUnit, bitDepth=bitDepth)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
import asposeimagingcloud
from asposeimagingcloud.ImagingApi import ImagingApi
from asposeimagingcloud.ImagingApi import ApiException
import asposestoragecloud
from asposestoragecloud.StorageApi import StorageApi
from asposestoragecloud.StorageApi import ResponseMessage
apiKey = "XXXXX" #sepcify App Key
appSid = "XXXXX" #sepcify App SID
apiServer = "http://api.aspose.com/v1.1"
data_folder = "../../data/"
#Instantiate Aspose Storage API SDK
storage_apiClient = asposestoragecloud.ApiClient.ApiClient(apiKey, appSid, True)
storageApi = StorageApi(storage_apiClient)
#Instantiate Aspose Imaging API SDK
api_client = asposeimagingcloud.ApiClient.ApiClient(apiKey, appSid, True)
imagingApi = ImagingApi(api_client);
#set input file name
name = "demo.tif"
compression = "ccittfax3"
resolutionUnit = "inch"
bitDepth = 1
try:
#invoke Aspose.Imaging Cloud SDK API to update Tiff specific properties without using cloud storage
response = imagingApi.PostProcessTiff(file=data_folder + name, compression=compression, resolutionUnit=resolutionUnit, bitDepth=bitDepth)
if response.Status == 'OK':
#download image from API response
outfilename = "c:/temp/" + name
with open(outfilename, 'wb') as f:
for chunk in response.InputStream:
f.write(chunk)
except ApiException as ex:
print "ApiException:"
print "Code:" + str(ex.code)
print "Message:" + ex.message
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment