1. Products
  2.   Image
  3.   Python
  4.   Aspose.Imaging Cloud SDK for Python

Aspose.Imaging Cloud SDK for Python

 
 

Python REST API to Create & Convert Images

Python REST SDK for Image Processing, enables Software Developers to Create, Edit, Compress, Manipulate, Convert, and Compress Images.

Images are an essential part of modern-day communication, with applications in fields such as social media, advertising, healthcare, and more. Creating as well as processing images efficiently and accurately is a very critical requirement for many modern-day businesses. Fortunately, Aspose.Imaging Cloud SDK for Python offers a comprehensive solution for working with images, enabling software developers to perform various important tasks such as creating, converting, resizing, cropping, viewing, printing, and many more. One of the main advantages of Aspose.Imaging Cloud SDK for Python is that it enables software developers to process images without requiring any specialized software or hardware.

Aspose.Imaging Cloud SDK for Python is a cloud-based API that allows developers to work with various types of images in various formats such as BMP, GIF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, WMF, EMF, SVG, and many more. There several other important features are also part of the library such as extracting meta-data from images, color management support, working with multiple layers in an image, adding/removing or modifying layers, adding watermarks to images (text and image watermarks), Image Flipping and Rotation, correcting image orientation issues, changing the perspective of an image and many more

Aspose.Imaging Cloud SDK for Python is very easy to handle and, allows developers to easily convert images from one format to another, such as converting a PNG image to JPEG or BMP. The SDK supports a wide range of image formats, making it highly versatile. Another very useful feature of the SDK is that users can also resize images with the SDK, which is useful for optimizing images for specific purposes such as social media posts or website design. The SDK supports both proportional and non-proportional resizing. Moreover, it allows users to crop images to remove unwanted portions or focus on specific areas of interest. Users can specify the cropping parameters such as the crop area and the crop mode.

Previous Next

Getting Started with Aspose.Imaging Cloud SDK for Python

The recommend way to install Aspose.Imaging Cloud SDK for Python is using PyPi. Please use the following command for a smooth installation.

Install Aspose.Imaging Cloud SDK for Python via PyPi

pip install aspose-imaging-cloud 
You can also download it directly from Aspose product page.

Read & Write Images in the Cloud via Python API

Aspose.Imaging Cloud SDK for Python is a very useful REST API that enables computer programmers to perform a wide range of image processing operations including creation, manipulation, and conversion in the cloud, with zero initial costs. The library has included support for some popular image file formats and allows reading and writing image file formats such as BMP, GIF, JPEG, JPEG2000, PSD, TIFF, WEBP, PNG, WMF, EMF, SVG, TGA, APNG, and so on. Once the images are created software developers can easily load and modify it according to their needs. The following example demonstrates how users can read an image from the cloud storage.

How to Read/Write an Image to/from the Cloud Storage via Python?

# set the input image path and format
name = 'input_image.jpg'
format = 'jpg'
folder = 'your_folder_path'

# send the request to the API to download the image
response = imaging_api.get_image_download(name, folder=folder, format=format)

# read the image data from the response
image_data = response.content

# Write an Image to the Cloud Storage via Python API

# set the output image path and format
name = 'output_image.jpg'
format = 'jpg'
folder = 'your_folder_path'

# send the request to the API to upload the image
response = imaging_api.create_updated_image(name, image_data, folder=folder, format=format)

# read the response to confirm the image was uploaded successfully
if response.status_code == 200:
    print('Image uploaded successfully.')
else:
    print('Error uploading image:', response.content)

Resize, Crop & Rotate Images via Python API

Aspose.Imaging Cloud SDK for Python enables software developers to perform various image manipulation operations inside their own cloud applications. To achieve the resizing tasks, developer needs to upload their image to Cloud Storage then pass its name in the API URL. After updating the image parameters, the API returns the updated image in the response. The REST API has included several important other features such as rotating flipping images, scaling images, cropping an existing image, append a TIFF image to another and many more.

How to Resize or Crop Images via Python API?

import asposeimagingcloudsdk
from asposeimagingcloudsdk.models.requests import CreateResizedImageRequest, CreateCroppedImageRequest

# Initialize Aspose.Imaging Cloud API client
imaging_api = asposeimagingcloudsdk.ImagingApi(api_key='YOUR_API_KEY', app_sid='YOUR_APP_SID')
# Set the input image file name and format
filename = 'input_image.jpg'
format = 'jpg'
# Set the output image file name and format
output_filename = 'output_image.jpg'
output_format = 'jpg'

# Set the new size for the resized image
new_width = 500
new_height = 500
# Set the coordinates and size of the area to be cropped
x = 50
y = 50
width = 400
height = 400
# Create a request object for creating the resized image
resize_request = CreateResizedImageRequest(filename, new_width, new_height, format, output_format, folder='input')
# Call the API to resize the image and save the result to the cloud storage
response = imaging_api.create_resized_image(resize_request)
# Create a request object for creating the cropped image
crop_request = CreateCroppedImageRequest(output_filename, output_format, x, y, width, height, format, folder='output')
# Call the API to crop the image and save the result to the cloud storage
response = imaging_api.create_cropped_image(crop_request)

Work with TIFF Frames via Python API

Aspose.Imaging Cloud SDK for Python has included very powerful support for TIFF (Tagged Image File Format) images inside Python applications. There are several important features part of the library for handling TIFF file formats such as extracting frame from a multi-frame TIFF image, getting TIFF frame properties, resizing a TIFF frame, TIFF Frame rotation or flipping support, cropping a TIFF frame, appending TIFF frames to another TIFF image, extracting individual TIFF frames for further processing and many more.

Advanced Images Searching in Cloud Apps

Aspose.Imaging Cloud SDK for Python has included very powerful support for searching images in different ways inside Python cloud applications. The library allows software developers to perform a reverse image search which means the source image set containing at least one image which is compared with several other images. Software developers can perform operations like compare two images, get image from search context, update images features in search context, find similar images, find duplicate images, search images by tags and many more.

How to Find Duplicate Images via Python API?

# optional parameters are base URL, API version and debug mode
imaging_api = ImagingApi('yourClientSecret', 'yourClientId')

# create search context or use existing search context ID if search context was
# created earlier
api_response = imaging_api.create_image_search(CreateImageSearchRequest())
search_context_id = api_response.id

# extract images features if it was not done before
imaging_api.create_image_features(CreateImageFeaturesRequest(
    search_context_id, image_id=None, images_folder='WorkFolder'))

# wait 'till image features extraction is completed
while imaging_api.get_image_search_status(
        GetImageSearchStatusRequest(
            search_context_id)).search_status != 'Idle':
    time.sleep(10)

# request finding duplicates
response = imaging_api.find_image_duplicates(
    FindImageDuplicatesRequest(search_context_id, 90))

# process duplicates search result
for duplicates in response.duplicates:
    print('Duplicates:')
    for duplicate in duplicates.duplicate_images:
        print('ImageName: {0}, Similarity: {1}'.format(duplicate.image_id,
                                                       duplicate.similarity))