Metadata-Version: 2.1
Name: aspose-imaging-python-net
Version: 24.7.0
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.
Home-page: https://products.aspose.com/imaging/python-net
Author: Aspose
License: Free To Use But Restricted,Other/Proprietary License
Project-URL: API Reference, https://reference.aspose.com/imaging/python-net/
Project-URL: Blog, https://blog.aspose.com/categories/aspose.imaging-product-family/
Project-URL: Demos, https://products.aspose.app/imaging/family
Project-URL: Docs, https://docs.aspose.com/imaging/python-net/
Project-URL: Examples, https://github.com/aspose-imaging/Aspose.Imaging-for-Python-NET
Project-URL: Free Support, https://forum.aspose.com/c/imaging
Project-URL: Release Notes, https://releases.aspose.com/imaging/python-net/release-notes/2024/aspose-imaging-for-python-net-24-7-release-notes/
Project-URL: Temporary License, https://purchase.aspose.com/temporary-license
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
Platform: win_amd64
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: Education
Classifier: Intended Audience :: Other Audience
Classifier: Operating System :: Microsoft :: Windows
Classifier: Operating System :: POSIX :: Linux
Classifier: Operating System :: Unix
Classifier: Operating System :: MacOS :: MacOS X
Classifier: Environment :: MacOS X
Classifier: Topic :: Office/Business
Classifier: Topic :: Software Development
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Multimedia :: Graphics
Classifier: Topic :: Multimedia :: Graphics :: Graphics Conversion
Classifier: Topic :: Scientific/Engineering :: Image Processing
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.5,<3.12
Description-Content-Type: text/markdown

## 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**|
| :- | :- | :- | :- |
|[BMP](https://docs.fileformat.com/image/bmp/)|BMP Specification v5|Yes|Yes|
|[GIF](https://docs.fileformat.com/image/gif/)|Version 89a|Yes|Yes|
|[DICOM](https://docs.fileformat.com/image/dicom/)|Version 3.0|Yes|Yes|
|[DJVU](https://docs.fileformat.com/image/djvu/)|Version 3.0|Yes| |
|[DNG](https://docs.fileformat.com/image/dng/)|Version 1.0.0.0 and later|Yes| |
|[EMF](https://docs.fileformat.com/image/emf/)|Revision 11.0|Yes|Yes|
|[JPEG](https://docs.fileformat.com/image/jpeg/)|CCITT Rec. T.81 (1992 E)|Yes|Yes|
|[JPEG2000](https://docs.fileformat.com/image/jp2/)|ITU-T Rec. T.800 (08/2002 E)|Yes|Yes|
|[ODG](https://docs.fileformat.com/image/odg/)|Version 1.2|Yes| |
|[PNG](https://docs.fileformat.com/image/png/)|Version 1.0 and later|Yes|Yes|
|[ICO](https://docs.fileformat.com/image/ico/)|Version 1.0 and later|Yes|Yes|
|[APNG](https://docs.fileformat.com/image/apng/)| |Yes|Yes|
|[PSD](https://docs.fileformat.com/image/psd/)|Adobe Photoshop 2.0 and later| |Yes|
|[DXF](https://docs.fileformat.com/cad/dxf/)|Dxf 6 and later| |Yes|
|[SVG](https://docs.fileformat.com/page-description-language/svg/)|Version 1.1|Yes|Yes|
|[TIFF](https://docs.fileformat.com/image/tiff/)|Version 6.0*|Yes|Yes|
|[BIG-TIFF](https://www.awaresystems.be/imaging/tiff/bigtiff.html)| |Yes|Yes|
|[DIB](https://docs.fileformat.com/image/dib/)|BMP Specification v5|Yes| |
|[EPS](https://docs.fileformat.com/page-description-language/eps/)| |Yes| |
|[WEBP](https://docs.fileformat.com/image/webp/)| |Yes| |
|[WMF](https://docs.fileformat.com/image/wmf/)|Revision 13.0|Yes|Yes|
|[CDR](https://docs.fileformat.com/image/cdr/)|Version X7, X6 (3-x5 not completely)|Yes| |
|[CMX](https://docs.fileformat.com/image/cmx/)|Version 2.0, 32 bit precision (16 bit precision not completely)|Yes| |
|[OTG](https://docs.fileformat.com/image/otg/)|Version 1.2|Yes| |
|[PDF](https://docs.fileformat.com/pdf/)|Portable document format| |Yes|
|[HTML5 canvas](https://docs.fileformat.com/web/html/)|Html5 canvas element| |Yes|
|[EMZ](https://docs.fileformat.com/image/emz/)|Compressed emf format|Yes|Yes|
|[WMZ](https://docs.fileformat.com/image/wmz/)|Compressed wmf format|Yes|Yes|
|[TGA](https://docs.fileformat.com/image/tga/)|Truevision TGA (TARGA)|Yes|Yes|
|[SVGZ](https://docs.fileformat.com/image/svgz/)|Compressed svg file 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 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)
