Skip to main content

Photo Layout

Project description

根据图像进行排版。比如排成二行三列的布局。

安装

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.layout import Canvas, LayoutModel
from photo_layout.image 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()

效果图如下:

https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example1.jpg

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

示例二

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

from photo_layout.layout import Canvas, LayoutModel
from photo_layout.image 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()

效果图如下:

https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example2.jpg

示例三

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

from photo_layout.layout import Canvas, LayoutModel
from photo_layout.image 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()

效果图如下:

https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example3.jpg

Project details


Download files

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

Source Distribution

photo-layout-1.0.5.tar.gz (26.6 kB view details)

Uploaded Source

Built Distribution

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

photo_layout-1.0.5-py3-none-any.whl (8.0 kB view details)

Uploaded Python 3

File details

Details for the file photo-layout-1.0.5.tar.gz.

File metadata

  • Download URL: photo-layout-1.0.5.tar.gz
  • Upload date:
  • Size: 26.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for photo-layout-1.0.5.tar.gz
Algorithm Hash digest
SHA256 0a678c70e61ea49dd8f4cd1b157cf4b23e1662f6e50fdd97bf7ef312f44085f3
MD5 e25939c398ef5a77faec4978ed5079b3
BLAKE2b-256 fa720c4291028eaec5162b518d1cf6afc007f1f65fd0700e839adba630e374d7

See more details on using hashes here.

File details

Details for the file photo_layout-1.0.5-py3-none-any.whl.

File metadata

  • Download URL: photo_layout-1.0.5-py3-none-any.whl
  • Upload date:
  • Size: 8.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.7.5

File hashes

Hashes for photo_layout-1.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 a80d33b2172180324bbd345d6b87326f1e356bfa0348ca1f8e43c331fd8e6c75
MD5 0ce5926cf34756d92df2ebd3022eb138
BLAKE2b-256 f22c259e09032b1e2639f600c250a551d5069ea868d3eeb0caf38f80b6a7abda

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page