Skip to main content

photo-layout

PyPI version Python License Documentation Status

一个 Python 图像排版工具,可以根据指定图片自动生成网格布局。支持自定义画布大小、背景色、行列数及间距,适用于多图拼接、照片墙等场景。


功能特点

  • 指定行列布局:设定行数和列数,自动计算画布大小并排列图片
  • 自动填充画布:指定画布尺寸后,自动计算可容纳的行列数并铺满
  • 裁剪溢出区域:通过 is_del_extra=True 裁剪画布中无法容纳的多余部分
  • 自定义样式:支持自定义背景色、图片间距等

安装

pip install photo-layout

对象相关描述

Canvas(width=None, height=None, color="white", is_del_extra=False)
  • width: 画布的宽度。
  • height: 画布的高度。
  • color: 画布的颜色。默认为白色 white。
  • is_del_extra:是否删除画布中额外多出的部分。
LayoutModel(canvas=Canvas, imagePath=None, row, column, space=10)
  • canvas:Canvas 对象。
  • imagePath:本地的图片路径。
  • row:行数。
  • column:列数。
  • space:间距。默认为 10。

示例一

from photo_layout import Canvas, LayoutModel
from photo_layout import LayoutImage

def main():
    canvas = Canvas(color="pink")
    layout_model = LayoutModel(canvas=canvas, imagePath="test.jpg", row=3, column=3, space=10)
    layout_image = LayoutImage(layout=layout_model)
    image = layout_image.create()
    image.show()

if __name__ == '__main__':
    main()

效果图如下:

example1

当然你也可以调用 image.save("imgs/example1.jpg") 来保存到本地。

示例二

根据图片来填充整个画布.

from photo_layout import Canvas, LayoutModel
from photo_layout import LayoutImage

def main():
    canvas = Canvas(width=2000, height=800, color="pink")
    layout_model = LayoutModel(canvas=canvas, imagePath="test.jpg", space=10)
    layout_image = LayoutImage(layout=layout_model)
    image = layout_image.create()
    image.show()

if __name__ == '__main__':
    main()

效果图如下:

example2

示例三

根据图片来填充整个画布. 通过设置 is_del_extra=True 来删除画布额外多出的部分。

from photo_layout import Canvas, LayoutModel
from photo_layout import LayoutImage

def main():
    canvas = Canvas(width=2000, height=800, color="pink", is_del_extra=True)
    layout_model = LayoutModel(canvas=canvas, imagePath="test.jpg", space=10)
    layout_image = LayoutImage(layout=layout_model)
    image = layout_image.create()
    image.show()

if __name__ == '__main__':
    main()

效果图如下:

example3

Metadata

Release files for photo-layout 1.0.9

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for photo-layout 1.0.9
File
photo_layout-1.0.9-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details
photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl CPython 3.14 CPython 3.14 Linux glibc 2.17+ x86-64 Details
photo_layout-1.0.9-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
photo_layout-1.0.9-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
photo_layout-1.0.9-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
photo_layout-1.0.9-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
photo_layout-1.0.9-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
photo_layout-1.0.9-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.17+ x86-64 Details

Total release size: 1.8 MB

Release files / photo_layout-1.0.9-cp314-cp314-win_amd64.whl

Download URL photo_layout-1.0.9-cp314-cp314-win_amd64.whl
Size 42.0 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
549e48e3ed3180627470bcdb8a6653984f69e46e66782b4aa6326b76d650945a
BLAKE2b-256 checksum
How to use checksums
85686233cdbf4bb33c08eff6c7b4776db307cd7c2c55a85f6f066e07c91ff11f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl
Size 220.4 kB
Tags CPython 3.14 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c731cfe8b8dd85f7731d1696f3375178dac959f8c4d2d3ab89580ab08b05960d
BLAKE2b-256 checksum
How to use checksums
f4fad83095cafedc8b05da79d55bb9170ebeca6a7567494b11243e8e62b035f2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp313-cp313-win_amd64.whl

Download URL photo_layout-1.0.9-cp313-cp313-win_amd64.whl
Size 40.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
9cfe233fb22dcae1ce05db16b2f0539477b2cce09cbc6f31a09e5c217f16e7de
BLAKE2b-256 checksum
How to use checksums
baecd980f980a4c3d489b1c51ce90799a4d2023053a130fcf1bf3c4c8415c3f1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl
Size 222.7 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3b3778843506b67e17866d76a9b3495d0a16f4a9473465bd4c90a4d89840bf7e
BLAKE2b-256 checksum
How to use checksums
93ae3800ed49e56b4815fc051af37eb5e5c07ea092f186b76ade03fa914b61c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp312-cp312-win_amd64.whl

Download URL photo_layout-1.0.9-cp312-cp312-win_amd64.whl
Size 42.3 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
2a162758ca0f8bf3836a94dac3a9a4f4f52ad049f96abb0e3e38225f4971401c
BLAKE2b-256 checksum
How to use checksums
67921947da35a8795598622506d28b542455ab6fc3a56ab1defc28cf8aa83080
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl
Size 232.3 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c1eb8746d87adb0222467a4b9d24b8093e571b79a6f9c93df928a9dd7d3d9746
BLAKE2b-256 checksum
How to use checksums
b340e940848536c6a440898faecf708c2f628dab7c9ebf636a54b50947a3597b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp311-cp311-win_amd64.whl

Download URL photo_layout-1.0.9-cp311-cp311-win_amd64.whl
Size 42.2 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
98147817d82c4760103a20ef7d360f9149d63d55193b576c12f63cd4b1a32aa3
BLAKE2b-256 checksum
How to use checksums
ff717a12b658101b6fe4ede11d3fa8b745fbdd323e701a5417e96d52ce75e35d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl
Size 216.7 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
9260b76d31c20246cb85f17de8567875e8d430e94c1d2ebe0784a43c3c89be3b
BLAKE2b-256 checksum
How to use checksums
ad295fc56fde3dc0698a054fdefff3b1966b5ef9dafe01415159b830e18276f7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp310-cp310-win_amd64.whl

Download URL photo_layout-1.0.9-cp310-cp310-win_amd64.whl
Size 42.3 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
87b7d9fec73d3dccd3f2eda19c1eb8e86e64424eb44219fb5144606b795c6007
BLAKE2b-256 checksum
How to use checksums
25cbbbb2ca24efceac727af043bf16bfb884067c6fb7587d030b528588d5ca7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl
Size 206.7 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
665f2d374d11a02f3a49c52fdb7f0e1f14d4b9c59c8b10a1752eb4a015772992
BLAKE2b-256 checksum
How to use checksums
5269e4786ef6d7359e9df0f78aa05441ce5fcf6e754f0e599ebc343f059c9b77
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp39-cp39-win_amd64.whl

Download URL photo_layout-1.0.9-cp39-cp39-win_amd64.whl
Size 55.1 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
4d864cb26ec057d9e40751fec0dccf4a17684b0a2f1584bf8fc318654224924b
BLAKE2b-256 checksum
How to use checksums
c49e4b664c13cfef4813aa19b0f8eb140ae2d6ff57fe6089ac6df1573c381893
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl
Size 205.7 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
dd68e5d75163ce134ad8eb8fb360c6c2e2b54b38b81fac52967ed5300774e83e
BLAKE2b-256 checksum
How to use checksums
e917ffc404ee96dd365b62a0174293f48608c7f50d9c1761e473356c0abe8c79
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp38-cp38-win_amd64.whl

Download URL photo_layout-1.0.9-cp38-cp38-win_amd64.whl
Size 56.1 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
b521412bc9d53318154f0ff84cd54abbb695479b9779c949be446a902adaec38
BLAKE2b-256 checksum
How to use checksums
bc210734d326e23a5829ca9a23275bf2552f6a21a533274d19bc5c9b17f0c746
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Release files / photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl

Download URL photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl
Size 212.0 kB
Tags CPython 3.8 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
47161510bd63bce117585edf88f1c146a57c507a41684c63553c83a9f5c375ec
BLAKE2b-256 checksum
How to use checksums
2b7be81143e8046219f4b46eb60e983e3b78e7defda0d91260740577527f8b84
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

Security for photo-layout 1.0.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 14 files in this release have been uploaded with provenance metadata.

Select from 14 files

Attestation for photo_layout-1.0.9-cp314-cp314-win_amd64.whl

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 25, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.9 This release

14 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page