Aspose.PSD  for Python via .NET

Python APIs to Manipulate Photoshop Files

Create, Read, Edit and Convert PSD, PSB & AI files without any Adobe Photoshop or Adobe Illustrator dependencies.

  Download Free Trial
  
 

Aspose.PSD for Python via .NET is an Unique Python PSD Library offering advanced PSD, PSD and AI files processing features. You could easily create, load, update, edit, convert, compress PSD and PSB images using this API. Aspose.PSD Supports most popular features for PSD and PSB files including updates of Text Layers, Smart Objects, Fill Layers, Shape Layers, Group Layers, Adjustment Layers. Aspose.PSD supports Blendings Modes, Layer Effects, Warp Transformations, Smart Filters, Animation TimeLine, Working with Vector, Raster and Clipping Masks, Low-Level PSD file resource exploring and much more

Aspose.PSD Supported formats

Advanced Python PSD Manipulation API Features

Open PSD File in Python and update text

Aspose.PSD for Python via .NET provides the capability to open and aedit PSD files with just a few lines of code.

Open file, Update Text, Export to Other Format like PDF, PNG, JPEG, TIFF, BMP, GIF - Python

from aspose.psd import Image
from aspose.psd.fileformats.png import PngColorType
from aspose.psd.fileformats.psd import PsdImage
from aspose.psd.fileformats.psd.layers import TextLayer
from aspose.psd.imageloadoptions import PsdLoadOptions
from aspose.psd.imageoptions import PngOptions
from aspose.pycore import cast
# Specify File Paths
sourceFile = "AllTypesLayerPsd.psd"
outputFile = "LoadImageExample.png"
# Specify Load Options
loadOptions = PsdLoadOptions()
loadOptions.load_effects_resource = True
loadOptions.allow_warp_repaint = True
# Specify Export Options
exportOptions = PngOptions()
exportOptions.color_type = PngColorType.TRUECOLOR_WITH_ALPHA
# Open File using Aspose.PSD for Python
with Image.load(sourceFile, loadOptions) as image:
# Types of Aspose.PSD can be casted
psdImage = cast(PsdImage, image)
textLayer = cast(TextLayer, psdImage.layers[5])
textLayer.update_text("Simple Text Edit")
# Export PSD File To PNG
psdImage.save(outputFile, exportOptions)

Read or Create PSD Files

Aspose.PSD for Python via .NET not only supports loading PSD & PSB file formats for manipulation & conversion but it also provides the capability to create PSD & PSB files from scratch. .NET developers can use the API to automate scenarios that may help them on their way.

Create PSD from scratch - Python

from aspose.psd import Graphics, Pen, Color, Rectangle
from aspose.psd.brushes import LinearGradientBrush
from aspose.psd.fileformats.psd import PsdImage
outputFile = "CreateFileFromScratchExample.psd"
# Create PSD Image with specified dimensions
with PsdImage(500, 500) as img:
# Create Regular PSD Layer and update it with Graphic API
regularLayer = img.add_regular_layer()
# Use popular Graphic API for Editing
graphics = Graphics(regularLayer)
pen = Pen(Color.alice_blue)
brush = LinearGradientBrush(Rectangle(250, 250, 150, 100), Color.red, Color.aquamarine, 45)
graphics.draw_ellipse(pen, Rectangle(100, 100, 200, 200))
graphics.fill_ellipse(brush, Rectangle(250, 250, 150, 100))
# Create Text Layer
textLayer = img.add_text_layer("Sample Text", Rectangle(200, 200, 100, 100))
# Adding Shadow to Text
dropShadowEffect = textLayer.blending_options.add_drop_shadow()
dropShadowEffect.distance = 0
dropShadowEffect.size = 8
dropShadowEffect.color = Color.blue
# Save PSD File
img.save(outputFile)

Add any file supported Graphic File as a Layer for editing in Photoshop-like style using Aspose.PSD for Python

Aspose.PSD for Python via .NET provides the capability to add any Image file as a layer and start its editing

Open file, Update Text, Export to Other Format like PDF, PNG, JPEG, TIFF, BMP, GIF - Python

from io import BytesIO
from aspose.psd.fileformats.psd import PsdImage
from aspose.psd.fileformats.psd.layers import Layer
inputFile = "inputFile.png"
outputFile = "AddFileAsLayer.psd"
# Open file as Stream
with open(inputFile, "rb", buffering=0) as filestream:
stream = BytesIO(filestream.read())
stream.seek(0)
# Create PSD Layer from Stream
layer = Layer(stream)
# Create PSD Image with the specified size
psdImage = PsdImage(layer.width, layer.height)
# Add Layer to PSD Image
psdImage.layers = [layer]
# Get Pixels from File
pixels = layer.load_argb_32_pixels(layer.bounds)
pixelsRange = range(len(pixels))
# Fill the pixels data with some values
for i in pixelsRange:
if i % 5 == 0:
pixels[i] = 500000
# Fast Save of Updated Image Data
layer.save_argb_32_pixels(layer.bounds, pixels)
# Save PSD Image
psdImage.save(outputFile)

Please check how the Aspose.PSD for Python License can be applied

Aspose.PSD for Python can be easily tested for your needs but the Library is paid, so you need to obtain license

Open file, Update Text, Export to Other Format like PDF, PNG, JPEG, TIFF, BMP, GIF - Python

from aspose.psd import License
license = License()
licensePath = "PathToLicenseFile"
license.set_license(licensePath)
  

Support and Learning Resources

  
  

Aspose.PSD offers individual PSD APIs for other popular development environments as listed below: