Quickstart
Bắt đầu nhanh
Ví dụ này tải một tài liệu PSD/PSB, in tiêu đề và siêu dữ liệu lớp, đổi tên lớp đầu tiên và lưu kết quả.
Yêu cầu trước
| Yêu cầu | Chi tiết |
|---|---|
| Python | Một trình thông dịch CPython được hỗ trợ |
| Package | Aspose.PSD FOSS cho Python đã được cài đặt — xem Installation |
- Tải tài liệu và in tiêu đề của nó.
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}")- In siêu dữ liệu của từng lớp.
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}")- Đổi tên lớp đầu tiên và lưu kết quả.
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")Các bước tiếp theo
- Cốt lõi API cho toàn bộ
PsdImage/Imagereference - Layers cho tài liệu tham chiếu siêu dữ liệu lớp đầy đủ
- Các ngoại lệ Core đối với xử lý lỗi tải/lưu