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)
  • canvasCanvas 对象。
  • 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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

photo_layout-1.0.9-cp314-cp314-win_amd64.whl (42.0 kB view details)

Uploaded CPython 3.14Windows x86-64

photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl (220.4 kB view details)

Uploaded CPython 3.14manylinux: glibc 2.17+ x86-64

photo_layout-1.0.9-cp313-cp313-win_amd64.whl (40.8 kB view details)

Uploaded CPython 3.13Windows x86-64

photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl (222.7 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

photo_layout-1.0.9-cp312-cp312-win_amd64.whl (42.3 kB view details)

Uploaded CPython 3.12Windows x86-64

photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl (232.3 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

photo_layout-1.0.9-cp311-cp311-win_amd64.whl (42.2 kB view details)

Uploaded CPython 3.11Windows x86-64

photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl (216.7 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

photo_layout-1.0.9-cp310-cp310-win_amd64.whl (42.3 kB view details)

Uploaded CPython 3.10Windows x86-64

photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl (206.7 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

photo_layout-1.0.9-cp39-cp39-win_amd64.whl (55.1 kB view details)

Uploaded CPython 3.9Windows x86-64

photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl (205.7 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

photo_layout-1.0.9-cp38-cp38-win_amd64.whl (56.1 kB view details)

Uploaded CPython 3.8Windows x86-64

photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl (212.0 kB view details)

Uploaded CPython 3.8manylinux: glibc 2.17+ x86-64

File details

Details for the file photo_layout-1.0.9-cp314-cp314-win_amd64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp314-cp314-win_amd64.whl
Algorithm Hash digest
SHA256 549e48e3ed3180627470bcdb8a6653984f69e46e66782b4aa6326b76d650945a
MD5 a7c5378b19f0135f5c6f1f7b5beec454
BLAKE2b-256 85686233cdbf4bb33c08eff6c7b4776db307cd7c2c55a85f6f066e07c91ff11f

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp314-cp314-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c731cfe8b8dd85f7731d1696f3375178dac959f8c4d2d3ab89580ab08b05960d
MD5 97cd2095dcc9cb208a36462da77abeb5
BLAKE2b-256 f4fad83095cafedc8b05da79d55bb9170ebeca6a7567494b11243e8e62b035f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp314-cp314-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp313-cp313-win_amd64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 9cfe233fb22dcae1ce05db16b2f0539477b2cce09cbc6f31a09e5c217f16e7de
MD5 7ae4561de4df9438b1337e95afc29428
BLAKE2b-256 baecd980f980a4c3d489b1c51ce90799a4d2023053a130fcf1bf3c4c8415c3f1

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp313-cp313-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 3b3778843506b67e17866d76a9b3495d0a16f4a9473465bd4c90a4d89840bf7e
MD5 601948ef411587382faacc1b9d71f828
BLAKE2b-256 93ae3800ed49e56b4815fc051af37eb5e5c07ea092f186b76ade03fa914b61c8

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp313-cp313-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp312-cp312-win_amd64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 2a162758ca0f8bf3836a94dac3a9a4f4f52ad049f96abb0e3e38225f4971401c
MD5 ea831cc2f61ae59e8d45251bb7bc1616
BLAKE2b-256 67921947da35a8795598622506d28b542455ab6fc3a56ab1defc28cf8aa83080

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp312-cp312-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 c1eb8746d87adb0222467a4b9d24b8093e571b79a6f9c93df928a9dd7d3d9746
MD5 ccdb7fb6880572d0d752123c82bd2383
BLAKE2b-256 b340e940848536c6a440898faecf708c2f628dab7c9ebf636a54b50947a3597b

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp312-cp312-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp311-cp311-win_amd64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 98147817d82c4760103a20ef7d360f9149d63d55193b576c12f63cd4b1a32aa3
MD5 f4b408c617467f0d615ec94780e3036e
BLAKE2b-256 ff717a12b658101b6fe4ede11d3fa8b745fbdd323e701a5417e96d52ce75e35d

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp311-cp311-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 9260b76d31c20246cb85f17de8567875e8d430e94c1d2ebe0784a43c3c89be3b
MD5 72144c36068cdac5ffa5e9cd45eea39d
BLAKE2b-256 ad295fc56fde3dc0698a054fdefff3b1966b5ef9dafe01415159b830e18276f7

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp311-cp311-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp310-cp310-win_amd64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 87b7d9fec73d3dccd3f2eda19c1eb8e86e64424eb44219fb5144606b795c6007
MD5 33b5cef26eb334f1d039bed7bd4d19ed
BLAKE2b-256 25cbbbb2ca24efceac727af043bf16bfb884067c6fb7587d030b528588d5ca7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp310-cp310-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 665f2d374d11a02f3a49c52fdb7f0e1f14d4b9c59c8b10a1752eb4a015772992
MD5 2dd610f77f18dea3abeac45cea9936f5
BLAKE2b-256 5269e4786ef6d7359e9df0f78aa05441ce5fcf6e754f0e599ebc343f059c9b77

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp310-cp310-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: photo_layout-1.0.9-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 55.1 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for photo_layout-1.0.9-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 4d864cb26ec057d9e40751fec0dccf4a17684b0a2f1584bf8fc318654224924b
MD5 4686c250be822b1e25051de42a632549
BLAKE2b-256 c49e4b664c13cfef4813aa19b0f8eb140ae2d6ff57fe6089ac6df1573c381893

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp39-cp39-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 dd68e5d75163ce134ad8eb8fb360c6c2e2b54b38b81fac52967ed5300774e83e
MD5 3ae393f8787369939a70bab448a78851
BLAKE2b-256 e917ffc404ee96dd365b62a0174293f48608c7f50d9c1761e473356c0abe8c79

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp39-cp39-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: photo_layout-1.0.9-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 56.1 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for photo_layout-1.0.9-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 b521412bc9d53318154f0ff84cd54abbb695479b9779c949be446a902adaec38
MD5 e6058b547721da1b550dd8766cab9445
BLAKE2b-256 bc210734d326e23a5829ca9a23275bf2552f6a21a533274d19bc5c9b17f0c746

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp38-cp38-win_amd64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl.

File metadata

File hashes

Hashes for photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl
Algorithm Hash digest
SHA256 47161510bd63bce117585edf88f1c146a57c507a41684c63553c83a9f5c375ec
MD5 e1bac1fd63988180a08d581e1092eaa3
BLAKE2b-256 2b7be81143e8046219f4b46eb60e983e3b78e7defda0d91260740577527f8b84

See more details on using hashes here.

Provenance

The following attestation bundles were made for photo_layout-1.0.9-cp38-cp38-manylinux_2_17_x86_64.whl:

Publisher: workflow.yml on zhenzi0322-package/photo-layout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Release history Release notifications | RSS feed

This release

1.0.9 This release

14 files

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