Quickstart

Quickstart

This example loads a PSD/PSB document, prints its header and layer metadata, renames the first layer, and saves the result.


Prerequisites

RequirementDetail
PythonA supported CPython interpreter
PackageAspose.PSD FOSS for Python installed — see Installation

  1. Load the document and print its header.
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load("input.psd") as image:
    print(f"Width: {image.width}, Height: {image.height}")
    print(f"ColorMode: {image.color_mode}, Version: {image.version}")
  1. Print each layer’s metadata.
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load("input.psd") as image:
    for layer in image.layers:
        print(f"{layer.name}: {layer.bounds}, Visible={layer.is_visible}")
  1. Rename the first layer and save the result.
from aspose_psd_foss.psdimage import PsdImage

with PsdImage.load("input.psd") as image:
    if image.layer_count > 0:
        image.layers[0].name = f"{image.layers[0].name} (edited)"
    image.save("output.psd")

Next Steps

See Also