## Imaging Manipulation API
[Product Page](https://products.aspose.com/imaging/python-net/) | [Documentation](https://docs.aspose.com/imaging/python-net/) | [Demos](https://products.aspose.app/imaging/family) | [Blog](https://blog.aspose.com/categories/aspose.imaging-product-family/) | [API Reference](https://reference.aspose.com/imaging/python-net/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/imaging) | [Temporary License](https://purchase.aspose.com/temporary-license) | [EULA](https://company.aspose.com/legal/eula)
---
Try our [free online Apps](https://products.aspose.app/imaging/family) demonstrating some of the most popular Aspose.Imaging functionality.
**Aspose.Imaging for Python via .NET** is **Another Python Imaging Library** offering advanced image processing features. You could easily create, load, manipulate, convert, compress images or photos using this API. Also **Aspose.Imaging** library supports drawing and work with graphic primitives. Image export and conversion (including uniform multi-page image processing) is the one of API core features along with image transformations (resize, crop, flip&rotate, binarization, grayscale, adjust, etc.), advanced image manipulation features (filtering, dithering, masking, deskewing) and memory optimization strategies.
**Aspose.Imaging for Python via .NET** is a flexible, stable and powerful API, capable of processing the most commonly used formats along with some special formats such as DjVu, DICOM, WebP & DNG. Moreover, it extends the native support for image formats & processing functions for .NET and .NET Core. **Aspose.Imaging** is cross-platform library, it is Windows x32/x64, Linux x64, and MacOS x64/Arm64 compatible.
> Aspose.Imaging for Python requires you to use python programming language. For Java and .NET languages, we recommend you get Aspose.Imaging for Java and Aspose.Imaging for .NET, respectively.
### Product Features
The following are Aspose.Imaging’s core features:
- Create images (raster, vector)
- Read images (raster, vector)
- Write images (raster, vector)
- **Draw lines, circles, ellipses, texts, complex paths, and images using the classes Graphics, SvgGraphics2D, EmfRecorderGraphics2D, WmfRecorderGraphics2D**
- Process images (including per-pixel modifications)
- Convert between different image formats as raster as vector
- **Support the large images with size more than 100000x100000 pixels**
- **Memory and performance management strategies**
### **Supported File Formats**
|**File format**|**Supported versions**|**Load**|**Save**|
| :- | :- | :- | :- |
|[APNG](https://docs.fileformat.com/image/apng/)|Animated Portable Network Graphics|Yes|Yes|
|[AVIF](https://docs.fileformat.com/image/avif/)|AVIF (AV1 Image File Format) Version 1.0+|Yes|No|
|[BIG-TIFF](https://en.wikipedia.org/wiki/TIFF)|BigTIFF is a TIFF variant file format which uses 64-bit offsets and supports much larger files (up to 18 exabytes in size).|Yes|Yes|
|[BMP](https://docs.fileformat.com/image/bmp/)|BMP Specification v5|Yes|Yes|
|[CDR](https://docs.fileformat.com/image/cdr/)|Version X7, X6 (3-x5 not completely)|Yes|No|
|[CMX](https://docs.fileformat.com/image/cmx/)|Version 2.0, 32 bit precision (16 bit precision not completely)|Yes|No|
|[DIB](https://docs.fileformat.com/image/dib/)|BMP Specification v5|Yes|No|
|[DICOM](https://docs.fileformat.com/image/dicom/)|Version 3.0|Yes|Yes|
|[DJVU](https://docs.fileformat.com/image/djvu/)|Version 3.0|Yes|No|
|[DNG](https://docs.fileformat.com/image/dng/)|Version 1.0.0.0 and later|Yes|No|
|[DXF](https://docs.fileformat.com/cad/dxf/)|Dxf 6 and later|No|Yes|
|[EMF](https://docs.fileformat.com/image/emf/)|Revision 11.0|Yes|Yes|
|[EMZ](https://docs.fileformat.com/image/emz/)|Compressed emf format|Yes|Yes|
|[EPS](https://docs.fileformat.com/page-description-language/eps/) |Encapsulated Postscript file format |Yes|No|
|[GIF](https://docs.fileformat.com/image/gif/)|Version 89a|Yes|Yes|
|[HTML5 canvas](https://docs.fileformat.com/web/html/)|Html5 canvas element|No|Yes|
|[ICO](https://docs.fileformat.com/image/ico/)|Version 1.0 and later|Yes|Yes|
|[JPEG2000](https://docs.fileformat.com/image/jp2/)|ITU-T Rec. T.800 (08/2002 E)|Yes|Yes|
|[JPEG](https://docs.fileformat.com/image/jpeg/)|CCITT Rec. T.81 (1992 E)|Yes|Yes|
|[ODG](https://docs.fileformat.com/image/odg/)|Version 1.2|Yes|No|
|[OTG](https://docs.fileformat.com/image/otg/)|Version 1.2|Yes|No|
|[PDF](https://docs.fileformat.com/pdf/)|Portable document format|No|Yes|
|[PNG](https://docs.fileformat.com/image/png/)|Version 1.0 and later|Yes|Yes|
|[PSD](https://docs.fileformat.com/image/psd/)|Adobe Photoshop 2.0 and later|No|Yes|
|[SVGZ](https://docs.fileformat.com/image/svgz/)|Compressed svg file format|Yes|Yes|
|[SVG](https://docs.fileformat.com/page-description-language/svg/)|Version 1.1|Yes|Yes|
|[TGA](https://docs.fileformat.com/image/tga/)|Truevision TGA (TARGA)|Yes|Yes|
|[TIFF](https://docs.fileformat.com/image/tiff/)|Version 6.0*|Yes|Yes|
|[WEBP](https://en.wikipedia.org/wiki/WebP)|WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression,[8] as well as animation and alpha transparency. |Yes|No|
|[WMF](https://docs.fileformat.com/image/wmf/)|Revision 13.0|Yes|Yes|
|[WMZ](https://docs.fileformat.com/image/wmz/)|Compressed wmf format|Yes|Yes|
### Platform Independence
Aspose.Imaging for Python can be used to develop applications for a vast range of operating systems, such as Windows (x32/x64), Linux (x64), and MacOS (x64/arm64) where Python 3.5 or later (since 3.13) is installed.
**The base .NET platform is .NET Core 6.0**
**Do not use System.Drawing.Common but the platform-independent Aspose.Drawing.**
### Get Started
Ready to give Aspose.Imaging for Python a try?
Simply run ```pip install aspose-imaging-python-net``` from the console to fetch the package. If you already have Aspose.Imaging for Python and want to upgrade the version, please run ```pip install --upgrade aspose-imaging-python-net``` to get the latest version.
You can run the following snippets in your environment to see how Aspose.Imaging works, or check out the [GitHub Repository](https://github.com/aspose-imaging/Aspose.Imaging-for-Python-Net) or [Aspose.Imaging for Python Documentation](https://docs.aspose.com/imaging/python-net/) for other common use cases.
### Create a PNG image from scratch in Python
``` python
from aspose.imaging import Color, Graphics, Pen
from aspose.imaging.fileformats.png import PngImage
# create an empty PNG image
with PngImage(100, 100) as png:
# create a canvas for drawing over the image
g = Graphics(png)
# start a queue of operations which will be processed together as a batch
g.begin_update()
# fill the background with blue color
g.clear(Color.blue)
# draw a line with light green pen with width == 2.0
g.draw_line(Pen(Color.light_green, 2.0), 0, 10, 100, 90)
# execute all drawing operations as one
g.end_update()
# save image in a file
png.save("output.png")
```
### Create and manipulate with PNG image
``` python
from aspose.imaging import Image, ResizeType, Graphics, Color, Pen, Rectangle
from aspose.imaging.fileformats.png import PngImage
from aspose.imaging.imageoptions import PngOptions
from aspose.imaging.sources import FileCreateSource
from aspose.pycore import as_of
import os
data_dir = "~/data-dir"
width = 500
height = 300
path = os.path.join(data_dir, "result.png")
with PngOptions() as options:
options.source = FileCreateSource(path, False)
with as_of(Image.create(options, width, height), PngImage) as image:
graphic = Graphics(image)
graphic.clear(Color.green)
graphic.draw_line(Pen(Color.blue), 9, 9, 90, 90)
new_width = 400
image.resize_width_proportionally(new_width, ResizeType.LANCZOS_RESAMPLE)
area = Rectangle(10, 10, 200, 200)
image.crop(area)
image.save() # save into the file set to options.source
```
### Load, resize and save a raster image
``` python
from aspose.imaging import Image
with Image.load("any-picture.tiff") as image:
image.resize(image.width // 2, image.height // 2)
image.save("output.jpeg")
```
### Load a raster image (PNG) and convert it into jpeg
``` python
from aspose.imaging import Image, FileFormat
from aspose.imaging.fileformats.png import PngImage
import aspose.pycore as pycore
with Image.load("any-picture.png") as image:
print("format: ", FileFormat(image.file_format).name)
# for accessing to a PngImage properties and methods need to cast it
png_image = pycore.as_of(image, PngImage)
print("xmp_data", png_image.xmp_data)
image.save("output.jpeg")
```
### Load jpeg and export it into the different formats
``` python
from aspose.imaging import Image
from aspose.imaging.fileformats.pdf import PdfDocumentInfo
from aspose.imaging.fileformats.tiff.enums import *
from aspose.imaging.imageoptions import *
import os
data_dir = "data-dir"
with Image.load(os.path.join(data_dir, "template.jpg")) as img:
# convert to webp
img.save(os.path.join(data_dir, "output.webp"), WebPOptions())
# convert to psd
img.save(os.path.join(data_dir, "output.psd "), PsdOptions())
# convert to tiff
img.save(os.path.join(data_dir, "output.tiff"), TiffOptions(TiffExpectedFormat.DEFAULT))
# convert to pdf
export_options = PdfOptions()
export_options.pdf_document_info = PdfDocumentInfo()
img.save(os.path.join(data_dir, "output.pdf"), export_options)
```
### Crop image
``` python
from aspose.pycore import as_of
from aspose.imaging import Image, Rectangle, RasterImage
import os
data_dir = "data-dir"
with Image.load(os.path.join(data_dir, "template.jpg")) as img:
# casting to the RasterImage class
raster_image = as_of(img, RasterImage)
# crop
area = Rectangle(10, 10, img.width - 20, img.height - 20)
raster_image.crop(area)
image.save("cropped.jpg")
```
### Merge images into one (collage)
``` python
from aspose.imaging import Image, Graphics, Color, RectangleF
from aspose.imaging.fileformats.png import PngColorType
from aspose.imaging.imageoptions import PngOptions
from aspose.imaging.sources import FileCreateSource
import os
data_dir = "data-dir"
images = []
# files for merging
files = ["template.png", "template.jpg"] # could be more file here
max_width = 0
max_height = 0
total_width = 0
total_height = 0
for file_name in files:
image = Image.load(os.path.join(data_dir, file_name))
total_width += image.width
if image.width > max_width:
max_width = image.width
total_height += image.height
if image.height > max_height:
max_height = image.height
images.append(image)
def merge_images(direction, out_file_name):
target_width = 0
target_height = 0
if direction == 0:
target_width = total_width
target_height = max_height
else:
target_width = max_width
target_height = total_height
output_path = os.path.join(data_dir, out_file_name + ".png")
with PngOptions() as png_options:
png_options.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
with open(out_file_name, "wb") as stream:
png_options.source = FileCreateSource(output_path, False)
with Image.create(png_options, target_width, target_height) as image:
image.background_color = Color.white
graphics = Graphics(image)
x = 0
y = 0
graphics.begin_update()
for frame in images:
print("x", x, "y", y)
graphics.draw_image(frame, RectangleF(x, y, frame.width, frame.height))
if direction == 0:
x += frame.width
if direction == 1:
y += frame.height
graphics.end_update()
image.save(output_path)
# run
merge_images(0, "collage_horizontal")
merge_images(1, "collage_vertical")
for image in images:
# to dispose the image we call __exit__()
with image as _:
pass
```
---
[Product Page](https://products.aspose.com/imaging/python-net/) | [Documentation](https://docs.aspose.com/imaging/python-net/) | [Demos](https://products.aspose.app/imaging/family) | [Blog](https://blog.aspose.com/categories/aspose.imaging-product-family/) | [API Reference](https://reference.aspose.com/imaging/python-net/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/imaging) | [Temporary License](https://purchase.aspose.com/temporary-license) | [EULA](https://company.aspose.com/legal/eula)
Raw data
{
"_id": null,
"home_page": "https://products.aspose.com/imaging/python-net",
"name": "aspose-imaging-python-net",
"maintainer": null,
"docs_url": null,
"requires_python": "<3.14,>=3.5",
"maintainer_email": null,
"keywords": "image, convert, manipulate, drawing, load, update, save, merge, crop, resize, flip, rotate, canvas, graphics, jpeg, png, gif, svg, tiff, bigtiff, bmp, dicom, eps, tga, webp, cdr, cmx, djvu, dng, tga, html5, dxf, raster, metafiles, wmf, emf, fodg, ico, pdf, svgz, emz, wmz",
"author": "Aspose",
"author_email": null,
"download_url": null,
"platform": "macos_x86_64",
"description": "## Imaging Manipulation API\n\n[Product Page](https://products.aspose.com/imaging/python-net/) | [Documentation](https://docs.aspose.com/imaging/python-net/) | [Demos](https://products.aspose.app/imaging/family) | [Blog](https://blog.aspose.com/categories/aspose.imaging-product-family/) | [API Reference](https://reference.aspose.com/imaging/python-net/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/imaging) | [Temporary License](https://purchase.aspose.com/temporary-license) | [EULA](https://company.aspose.com/legal/eula)\n\n---\nTry our [free online Apps](https://products.aspose.app/imaging/family) demonstrating some of the most popular Aspose.Imaging functionality.\n\n**Aspose.Imaging for Python via .NET** is **Another Python Imaging Library** offering advanced image processing features. You could easily create, load, manipulate, convert, compress images or photos using this API. Also **Aspose.Imaging** library supports drawing and work with graphic primitives. Image export and conversion (including uniform multi-page image processing) is the one of API core features along with image transformations (resize, crop, flip&rotate, binarization, grayscale, adjust, etc.), advanced image manipulation features (filtering, dithering, masking, deskewing) and memory optimization strategies.\n\n**Aspose.Imaging for Python via .NET** is a flexible, stable and powerful API, capable of processing the most commonly used formats along with some special formats such as DjVu, DICOM, WebP & DNG. Moreover, it extends the native support for image formats & processing functions for .NET and .NET Core. **Aspose.Imaging** is cross-platform library, it is Windows x32/x64, Linux x64, and MacOS x64/Arm64 compatible.\n\n> Aspose.Imaging for Python requires you to use python programming language. For Java and .NET languages, we recommend you get Aspose.Imaging for Java and Aspose.Imaging for .NET, respectively.\n\n\n### Product Features\n\nThe following are Aspose.Imaging\u2019s core features:\n- Create images (raster, vector)\n- Read images (raster, vector)\n- Write images (raster, vector)\n- **Draw lines, circles, ellipses, texts, complex paths, and images using the classes Graphics, SvgGraphics2D, EmfRecorderGraphics2D, WmfRecorderGraphics2D**\n- Process images (including per-pixel modifications)\n- Convert between different image formats as raster as vector\n- **Support the large images with size more than 100000x100000 pixels**\n- **Memory and performance management strategies**\n\n### **Supported File Formats**\n|**File format**|**Supported versions**|**Load**|**Save**|\n| :- | :- | :- | :- |\n|[APNG](https://docs.fileformat.com/image/apng/)|Animated Portable Network Graphics|Yes|Yes|\n|[AVIF](https://docs.fileformat.com/image/avif/)|AVIF (AV1 Image File Format) Version 1.0+|Yes|No|\n|[BIG-TIFF](https://en.wikipedia.org/wiki/TIFF)|BigTIFF is a TIFF variant file format which uses 64-bit offsets and supports much larger files (up to 18 exabytes in size).|Yes|Yes|\n|[BMP](https://docs.fileformat.com/image/bmp/)|BMP Specification v5|Yes|Yes|\n|[CDR](https://docs.fileformat.com/image/cdr/)|Version X7, X6 (3-x5 not completely)|Yes|No|\n|[CMX](https://docs.fileformat.com/image/cmx/)|Version 2.0, 32 bit precision (16 bit precision not completely)|Yes|No|\n|[DIB](https://docs.fileformat.com/image/dib/)|BMP Specification v5|Yes|No|\n|[DICOM](https://docs.fileformat.com/image/dicom/)|Version 3.0|Yes|Yes|\n|[DJVU](https://docs.fileformat.com/image/djvu/)|Version 3.0|Yes|No|\n|[DNG](https://docs.fileformat.com/image/dng/)|Version 1.0.0.0 and later|Yes|No|\n|[DXF](https://docs.fileformat.com/cad/dxf/)|Dxf 6 and later|No|Yes|\n|[EMF](https://docs.fileformat.com/image/emf/)|Revision 11.0|Yes|Yes|\n|[EMZ](https://docs.fileformat.com/image/emz/)|Compressed emf format|Yes|Yes|\n|[EPS](https://docs.fileformat.com/page-description-language/eps/) |Encapsulated Postscript file format\u00a0|Yes|No|\n|[GIF](https://docs.fileformat.com/image/gif/)|Version 89a|Yes|Yes|\n|[HTML5 canvas](https://docs.fileformat.com/web/html/)|Html5 canvas element|No|Yes|\n|[ICO](https://docs.fileformat.com/image/ico/)|Version 1.0 and later|Yes|Yes|\n|[JPEG2000](https://docs.fileformat.com/image/jp2/)|ITU-T Rec. T.800 (08/2002 E)|Yes|Yes|\n|[JPEG](https://docs.fileformat.com/image/jpeg/)|CCITT Rec. T.81 (1992 E)|Yes|Yes|\n|[ODG](https://docs.fileformat.com/image/odg/)|Version 1.2|Yes|No|\n|[OTG](https://docs.fileformat.com/image/otg/)|Version 1.2|Yes|No|\n|[PDF](https://docs.fileformat.com/pdf/)|Portable document format|No|Yes|\n|[PNG](https://docs.fileformat.com/image/png/)|Version 1.0 and later|Yes|Yes|\n|[PSD](https://docs.fileformat.com/image/psd/)|Adobe Photoshop 2.0 and later|No|Yes|\n|[SVGZ](https://docs.fileformat.com/image/svgz/)|Compressed svg file format|Yes|Yes|\n|[SVG](https://docs.fileformat.com/page-description-language/svg/)|Version 1.1|Yes|Yes|\n|[TGA](https://docs.fileformat.com/image/tga/)|Truevision TGA (TARGA)|Yes|Yes|\n|[TIFF](https://docs.fileformat.com/image/tiff/)|Version 6.0*|Yes|Yes|\n|[WEBP](https://en.wikipedia.org/wiki/WebP)|WebP is a raster graphics file format developed by Google intended as a replacement for JPEG, PNG, and GIF file formats. It supports both lossy and lossless compression,[8] as well as animation and alpha transparency. \u00a0|Yes|No|\n|[WMF](https://docs.fileformat.com/image/wmf/)|Revision 13.0|Yes|Yes|\n|[WMZ](https://docs.fileformat.com/image/wmz/)|Compressed wmf format|Yes|Yes|\n\n### Platform Independence\n\nAspose.Imaging for Python can be used to develop applications for a vast range of operating systems, such as Windows (x32/x64), Linux (x64), and MacOS (x64/arm64) where Python 3.5 or later (since 3.13) is installed.\n\n**The base .NET platform is .NET Core 6.0**\n**Do not use System.Drawing.Common but the platform-independent Aspose.Drawing.**\n\n### Get Started\n\nReady to give Aspose.Imaging for Python a try?\n\nSimply run ```pip install aspose-imaging-python-net``` from the console to fetch the package. If you already have Aspose.Imaging for Python and want to upgrade the version, please run ```pip install --upgrade aspose-imaging-python-net``` to get the latest version.\n\nYou can run the following snippets in your environment to see how Aspose.Imaging works, or check out the [GitHub Repository](https://github.com/aspose-imaging/Aspose.Imaging-for-Python-Net) or [Aspose.Imaging for Python Documentation](https://docs.aspose.com/imaging/python-net/) for other common use cases.\n\n### Create a PNG image from scratch in Python\n``` python\n\nfrom aspose.imaging import Color, Graphics, Pen\nfrom aspose.imaging.fileformats.png import PngImage\n\n# create an empty PNG image\nwith PngImage(100, 100) as png:\n\t# create a canvas for drawing over the image\n\tg = Graphics(png)\n\t# start a queue of operations which will be processed together as a batch\n\tg.begin_update()\n\t# fill the background with blue color\n\tg.clear(Color.blue)\n\t# draw a line with light green pen with width == 2.0\n\tg.draw_line(Pen(Color.light_green, 2.0), 0, 10, 100, 90)\n\t# execute all drawing operations as one\n\tg.end_update()\n\t# save image in a file\n\tpng.save(\"output.png\")\n\t\n```\n\n### Create and manipulate with PNG image\n``` python\n\nfrom aspose.imaging import Image, ResizeType, Graphics, Color, Pen, Rectangle\nfrom aspose.imaging.fileformats.png import PngImage\nfrom aspose.imaging.imageoptions import PngOptions\nfrom aspose.imaging.sources import FileCreateSource\nfrom aspose.pycore import as_of\nimport os\n\ndata_dir = \"~/data-dir\"\nwidth = 500\nheight = 300\npath = os.path.join(data_dir, \"result.png\")\nwith PngOptions() as options:\n\toptions.source = FileCreateSource(path, False)\n\twith as_of(Image.create(options, width, height), PngImage) as image:\n\t\tgraphic = Graphics(image)\n\t\tgraphic.clear(Color.green)\n\t\tgraphic.draw_line(Pen(Color.blue), 9, 9, 90, 90)\n\t\tnew_width = 400\n\t\timage.resize_width_proportionally(new_width, ResizeType.LANCZOS_RESAMPLE)\n\t\tarea = Rectangle(10, 10, 200, 200)\n\t\timage.crop(area)\n\t\timage.save() # save into the file set to options.source\n```\n\n### Load, resize and save a raster image\n``` python\n\nfrom aspose.imaging import Image\n\nwith Image.load(\"any-picture.tiff\") as image:\n\timage.resize(image.width // 2, image.height // 2)\n\timage.save(\"output.jpeg\")\n```\n\n\n### Load a raster image (PNG) and convert it into jpeg\n``` python\n\nfrom aspose.imaging import Image, FileFormat\nfrom aspose.imaging.fileformats.png import PngImage\nimport aspose.pycore as pycore\n\nwith Image.load(\"any-picture.png\") as image:\n\tprint(\"format: \", FileFormat(image.file_format).name)\n\t# for accessing to a PngImage properties and methods need to cast it\n\tpng_image = pycore.as_of(image, PngImage)\n\tprint(\"xmp_data\", png_image.xmp_data)\n\t\n\timage.save(\"output.jpeg\")\n \n```\n\n### Load jpeg and export it into the different formats\n``` python\n\nfrom aspose.imaging import Image\nfrom aspose.imaging.fileformats.pdf import PdfDocumentInfo\nfrom aspose.imaging.fileformats.tiff.enums import *\nfrom aspose.imaging.imageoptions import *\nimport os\n\ndata_dir = \"data-dir\"\nwith Image.load(os.path.join(data_dir, \"template.jpg\")) as img:\n\t# convert to webp\n\timg.save(os.path.join(data_dir, \"output.webp\"), WebPOptions())\n\t# convert to psd\n\timg.save(os.path.join(data_dir, \"output.psd \"), PsdOptions())\n\t# convert to tiff\n\timg.save(os.path.join(data_dir, \"output.tiff\"), TiffOptions(TiffExpectedFormat.DEFAULT))\n\t# convert to pdf\n\texport_options = PdfOptions()\n\texport_options.pdf_document_info = PdfDocumentInfo()\n\timg.save(os.path.join(data_dir, \"output.pdf\"), export_options)\n\n```\n\n### Crop image\n``` python\n\nfrom aspose.pycore import as_of\nfrom aspose.imaging import Image, Rectangle, RasterImage\nimport os\n\ndata_dir = \"data-dir\"\nwith Image.load(os.path.join(data_dir, \"template.jpg\")) as img:\n\t# casting to the RasterImage class\n\traster_image = as_of(img, RasterImage)\n\t# crop\n\tarea = Rectangle(10, 10, img.width - 20, img.height - 20)\n\traster_image.crop(area)\n\timage.save(\"cropped.jpg\")\n```\n\n### Merge images into one (collage)\n``` python\nfrom aspose.imaging import Image, Graphics, Color, RectangleF\nfrom aspose.imaging.fileformats.png import PngColorType\nfrom aspose.imaging.imageoptions import PngOptions\nfrom aspose.imaging.sources import FileCreateSource\nimport os\n\ndata_dir = \"data-dir\"\nimages = []\n# files for merging\nfiles = [\"template.png\", \"template.jpg\"] # could be more file here\nmax_width = 0\nmax_height = 0\ntotal_width = 0\ntotal_height = 0\nfor file_name in files:\n\timage = Image.load(os.path.join(data_dir, file_name))\n\ttotal_width += image.width\n\tif image.width > max_width:\n\t\tmax_width = image.width\n\ttotal_height += image.height\n\tif image.height > max_height:\n\t\tmax_height = image.height\n\timages.append(image)\n\n\ndef merge_images(direction, out_file_name):\n\ttarget_width = 0\n\ttarget_height = 0\n\tif direction == 0:\n\t\ttarget_width = total_width\n\t\ttarget_height = max_height\n\telse:\n\t\ttarget_width = max_width\n\t\ttarget_height = total_height\n\n\toutput_path = os.path.join(data_dir, out_file_name + \".png\")\n\twith PngOptions() as png_options:\n\t\tpng_options.color_type = PngColorType.TRUECOLOR_WITH_ALPHA\n\t\t\n\t\twith open(out_file_name, \"wb\") as stream:\n\t\t\tpng_options.source = FileCreateSource(output_path, False)\n\t\t\twith Image.create(png_options, target_width, target_height) as image:\n\t\t\t\timage.background_color = Color.white\n\t\t\t\tgraphics = Graphics(image)\n\t\t\t\tx = 0\n\t\t\t\ty = 0\n\t\t\t\tgraphics.begin_update()\n\t\t\t\tfor frame in images:\n\t\t\t\t\tprint(\"x\", x, \"y\", y)\n\t\t\t\t\tgraphics.draw_image(frame, RectangleF(x, y, frame.width, frame.height))\n\t\t\t\t\tif direction == 0:\n\t\t\t\t\t\tx += frame.width\n\t\t\t\t\tif direction == 1:\n\t\t\t\t\t\ty += frame.height\n\t\t\t\t\t\t\n\t\t\t\tgraphics.end_update()\n\t\t\t\timage.save(output_path)\n\n\n# run \nmerge_images(0, \"collage_horizontal\")\nmerge_images(1, \"collage_vertical\")\n\nfor image in images:\n\t# to dispose the image we call __exit__()\n\twith image as _:\n\t\tpass\n\n```\n\n---\n[Product Page](https://products.aspose.com/imaging/python-net/) | [Documentation](https://docs.aspose.com/imaging/python-net/) | [Demos](https://products.aspose.app/imaging/family) | [Blog](https://blog.aspose.com/categories/aspose.imaging-product-family/) | [API Reference](https://reference.aspose.com/imaging/python-net/) | [Search](https://search.aspose.com/) | [Free Support](https://forum.aspose.com/c/imaging) | [Temporary License](https://purchase.aspose.com/temporary-license) | [EULA](https://company.aspose.com/legal/eula)\n\n\n",
"bugtrack_url": null,
"license": "Free To Use But Restricted,Other/Proprietary License",
"summary": "Aspose.Imaging for Python via .NET is Another Python Imaging Library. It allows developers to easily create, load, manipulate, convert, compress images or photos using this API.",
"version": "25.7.0",
"project_urls": {
"API Reference": "https://reference.aspose.com/imaging/python-net/",
"Blog": "https://blog.aspose.com/categories/aspose.imaging-product-family/",
"Demos": "https://products.aspose.app/imaging/family",
"Docs": "https://docs.aspose.com/imaging/python-net/",
"Examples": "https://github.com/aspose-imaging/Aspose.Imaging-for-Python-NET",
"Free Support": "https://forum.aspose.com/c/imaging",
"Homepage": "https://products.aspose.com/imaging/python-net",
"Release Notes": "https://releases.aspose.com/imaging/python-net/release-notes/2025/aspose-imaging-for-python-net-25-7-release-notes/",
"Temporary License": "https://purchase.aspose.com/temporary-license"
},
"split_keywords": [
"image",
" convert",
" manipulate",
" drawing",
" load",
" update",
" save",
" merge",
" crop",
" resize",
" flip",
" rotate",
" canvas",
" graphics",
" jpeg",
" png",
" gif",
" svg",
" tiff",
" bigtiff",
" bmp",
" dicom",
" eps",
" tga",
" webp",
" cdr",
" cmx",
" djvu",
" dng",
" tga",
" html5",
" dxf",
" raster",
" metafiles",
" wmf",
" emf",
" fodg",
" ico",
" pdf",
" svgz",
" emz",
" wmz"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "16b6dc569f97b56cfd59d10047e5d5d78fa502a186370feece298fb226bb4f58",
"md5": "bdde11f00bea545d4112008077bd49e0",
"sha256": "b3c672c986e09800874cb1b1321b32989171e4a39ec3a8232de661b5734131d1"
},
"downloads": -1,
"filename": "aspose_imaging_python_net-25.7.0-py3-none-macosx_10_14_x86_64.whl",
"has_sig": false,
"md5_digest": "bdde11f00bea545d4112008077bd49e0",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.5",
"size": 92550634,
"upload_time": "2025-07-10T00:25:06",
"upload_time_iso_8601": "2025-07-10T00:25:06.203553Z",
"url": "https://files.pythonhosted.org/packages/16/b6/dc569f97b56cfd59d10047e5d5d78fa502a186370feece298fb226bb4f58/aspose_imaging_python_net-25.7.0-py3-none-macosx_10_14_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "078c7bd2efdf86d5c446c0f4afa2fcc41551fa96e46634477db7e0fa20daca09",
"md5": "71eb17d3e41aed45a052388d860729e4",
"sha256": "d59142f116f9a1c75b84aafa9f0785ac9eb431ec60a3b72ffe98369a7f62524c"
},
"downloads": -1,
"filename": "aspose_imaging_python_net-25.7.0-py3-none-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "71eb17d3e41aed45a052388d860729e4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.5",
"size": 72298561,
"upload_time": "2025-07-10T00:26:09",
"upload_time_iso_8601": "2025-07-10T00:26:09.202102Z",
"url": "https://files.pythonhosted.org/packages/07/8c/7bd2efdf86d5c446c0f4afa2fcc41551fa96e46634477db7e0fa20daca09/aspose_imaging_python_net-25.7.0-py3-none-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "70b64d7bf613822dee53142a9d5199882c6a145fd3a791ae5c9138487a5ea1a9",
"md5": "b51c45ef883bc556005a80b930039f69",
"sha256": "e043134254a630beb6ff011d9b72b40682655007652b30d4af38c799b6298282"
},
"downloads": -1,
"filename": "aspose_imaging_python_net-25.7.0-py3-none-manylinux1_x86_64.whl",
"has_sig": false,
"md5_digest": "b51c45ef883bc556005a80b930039f69",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.5",
"size": 105796665,
"upload_time": "2025-07-10T00:27:27",
"upload_time_iso_8601": "2025-07-10T00:27:27.679999Z",
"url": "https://files.pythonhosted.org/packages/70/b6/4d7bf613822dee53142a9d5199882c6a145fd3a791ae5c9138487a5ea1a9/aspose_imaging_python_net-25.7.0-py3-none-manylinux1_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "47be0efa4d14bba3d4415186fd59933c91da756ca832f061a8f3c60f93a37fbb",
"md5": "6775f1e9a6237b4e358528d58db839f3",
"sha256": "947c2c356da932ee25cb6f7ef69a155ac415a2246334f75d004aff0e1068d96a"
},
"downloads": -1,
"filename": "aspose_imaging_python_net-25.7.0-py3-none-win32.whl",
"has_sig": false,
"md5_digest": "6775f1e9a6237b4e358528d58db839f3",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.5",
"size": 61416744,
"upload_time": "2025-07-10T00:28:13",
"upload_time_iso_8601": "2025-07-10T00:28:13.533576Z",
"url": "https://files.pythonhosted.org/packages/47/be/0efa4d14bba3d4415186fd59933c91da756ca832f061a8f3c60f93a37fbb/aspose_imaging_python_net-25.7.0-py3-none-win32.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "8649fc809ae9d4c112d99b601b7818255c72973b4f0d4fc6e4d8ffd4e1d47154",
"md5": "635d2235a46f98d6e38b67947292adbd",
"sha256": "0ef6bda7f21b19f62f599ec1efff0b64658c3df4ea2e756eb597272152ba4386"
},
"downloads": -1,
"filename": "aspose_imaging_python_net-25.7.0-py3-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "635d2235a46f98d6e38b67947292adbd",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<3.14,>=3.5",
"size": 71453143,
"upload_time": "2025-07-10T00:29:10",
"upload_time_iso_8601": "2025-07-10T00:29:10.104020Z",
"url": "https://files.pythonhosted.org/packages/86/49/fc809ae9d4c112d99b601b7818255c72973b4f0d4fc6e4d8ffd4e1d47154/aspose_imaging_python_net-25.7.0-py3-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-10 00:25:06",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "aspose-imaging",
"github_project": "Aspose.Imaging-for-Python-NET",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "aspose-imaging-python-net"
}