This blog post is for you if you are a Python developer and working on a project for designers. You will learn how to create a PSB file in Python programmatically. We will opt for Aspose.PSD for Python via .NET for this purpose. In fact, this Python SDK is lightweight, secure, and robust, as you can integrate it into your project quickly. Additionally, you can create, manipulate, and convert Photoshop files without installing any third-party library. Moreover, it supports a wide range of file formats and smart filters. So, no more words, let’s go straight to the implementation.
Aspose.PDF for Python via .NET - Installation
In order to install Aspose.PSD for Python via .NET, simply click here or run the following command in terminal/CMD:
pip install aspose-psd
Create a PSB File in Python - Code Sample
This is the section that will walk through the steps and the code snippet.
Steps:
- Create a new PSD image with 500x500 dimensions.
- Add a regular layer to the PSD image by calling the add_regular_layer method.
- Create a Graphics object to draw on the regular layer.
- Create a pen with AliceBlue color for stroke (outline).
- Create a linear gradient brush to fill shapes from red to aquamarine.
- Draw an ellipse (circle-like shape) using the pen.
- Fill another ellipse with the gradient brush.
- Add a text layer with the text “Sample Text” inside a rectangular area.
- Add a drop shadow effect to the text layer.
- Call the save method to save the final image to the output file.
Now, you can create a PSB file in Python using the code snippet given below:
Output:
Get a Free License
Get a free temporary license to try this SDK beyond evaluation limitations.
Have questions?
Ask your questions on our forum.
Summing up
To conclude, Aspose.PSD for Python via .NET has brought efficiency in dealing with Photoshop files programmatically. It does offer a free licence to try out its features. So, you must not skip this SDK without giving it a try. This article demonstrated how to create a PSB file in Python. However, we will write about further features offered by this Python SDK. Stay tuned.
The following resources will give you deep insights: