photo-layout
============
根据图像进行排版。比如排成二行三列的布局。
安装
----
.. code:: cmd
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``\ 。
示例一
------
.. code:: python
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()
效果图如下:
.. image:: https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example1.jpg
当然你也可以调用\ ``image.save("imgs/example1.jpg")``\ 来保存到本地。
示例二
------
根据图片来填充整个画布.
.. code:: python
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()
效果图如下:
.. image:: https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example2.jpg
示例三
------
根据图片来填充整个画布.
通过设置\ ``is_del_extra=True``\ 来删除画布额外多出的部分。
.. code:: python
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()
效果图如下:
.. image:: https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example3.jpg
Raw data
{
"_id": null,
"home_page": "https://github.com/zhenzi0322/photo-layout",
"name": "photo-layout",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3",
"maintainer_email": "",
"keywords": "photo-layout",
"author": "\u7389\u632f",
"author_email": "82131529@qq.com",
"download_url": "https://files.pythonhosted.org/packages/fa/72/0c4291028eaec5162b518d1cf6afc007f1f65fd0700e839adba630e374d7/photo-layout-1.0.5.tar.gz",
"platform": null,
"description": "photo-layout\r\n============\r\n\r\n\u6839\u636e\u56fe\u50cf\u8fdb\u884c\u6392\u7248\u3002\u6bd4\u5982\u6392\u6210\u4e8c\u884c\u4e09\u5217\u7684\u5e03\u5c40\u3002\r\n\r\n\u5b89\u88c5\r\n----\r\n\r\n.. code:: cmd\r\n\r\n pip install photo-layout\r\n\r\n\u5bf9\u8c61\u76f8\u5173\u63cf\u8ff0\r\n------------\r\n\r\n::\r\n\r\n Canvas(width=None, height=None, color=\"white\", is_del_extra=False)\r\n\r\n- ``width``: \u753b\u5e03\u7684\u5bbd\u5ea6\u3002\r\n- ``height``: \u753b\u5e03\u7684\u9ad8\u5ea6\u3002\r\n- ``color``: \u753b\u5e03\u7684\u989c\u8272\u3002\u9ed8\u8ba4\u4e3a\u767d\u8272\\ ``white``\\ \u3002\r\n- ``is_del_extra``\\ \uff1a\u662f\u5426\u5220\u9664\u753b\u5e03\u4e2d\u989d\u5916\u591a\u51fa\u7684\u90e8\u5206\u3002\r\n\r\n::\r\n\r\n LayoutModel(canvas=Canvas, imagePath=None, row, column, space=10)\r\n\r\n- ``canvas``: ``Canvas``\\ \u5bf9\u8c61\u3002\r\n- ``imagePath``\\ \uff1a\u672c\u5730\u7684\u56fe\u7247\u8def\u5f84\u3002\r\n- ``row``\\ \uff1a\u884c\u6570\u3002\r\n- ``column``\\ \uff1a\u5217\u6570\u3002\r\n- ``space``\\ \uff1a\u95f4\u8ddd\u3002\u9ed8\u8ba4\u4e3a\\ ``10``\\ \u3002\r\n\r\n\u793a\u4f8b\u4e00\r\n------\r\n\r\n.. code:: python\r\n\r\n from photo_layout.layout import Canvas, LayoutModel\r\n from photo_layout.image import LayoutImage\r\n\r\n\r\n def main():\r\n canvas = Canvas(color=\"pink\")\r\n layout_model = LayoutModel(canvas=canvas, imagePath=\"test.jpg\", row=3, column=3, space=10)\r\n layout_image = LayoutImage(layout=layout_model)\r\n image = layout_image.create()\r\n image.show()\r\n\r\n\r\n if __name__ == '__main__':\r\n main()\r\n\r\n\u6548\u679c\u56fe\u5982\u4e0b\uff1a\r\n\r\n.. image:: https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example1.jpg\r\n\r\n\u5f53\u7136\u4f60\u4e5f\u53ef\u4ee5\u8c03\u7528\\ ``image.save(\"imgs/example1.jpg\")``\\ \u6765\u4fdd\u5b58\u5230\u672c\u5730\u3002\r\n\r\n\u793a\u4f8b\u4e8c\r\n------\r\n\r\n \u6839\u636e\u56fe\u7247\u6765\u586b\u5145\u6574\u4e2a\u753b\u5e03.\r\n\r\n.. code:: python\r\n\r\n from photo_layout.layout import Canvas, LayoutModel\r\n from photo_layout.image import LayoutImage\r\n\r\n\r\n def main():\r\n canvas = Canvas(width=2000, height=800, color=\"pink\")\r\n layout_model = LayoutModel(canvas=canvas, imagePath=\"test.jpg\", space=10)\r\n layout_image = LayoutImage(layout=layout_model)\r\n image = layout_image.create()\r\n image.show()\r\n\r\n\r\n if __name__ == '__main__':\r\n main()\r\n\r\n\u6548\u679c\u56fe\u5982\u4e0b\uff1a\r\n\r\n.. image:: https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example2.jpg\r\n\r\n\u793a\u4f8b\u4e09\r\n------\r\n\r\n \u6839\u636e\u56fe\u7247\u6765\u586b\u5145\u6574\u4e2a\u753b\u5e03.\r\n \u901a\u8fc7\u8bbe\u7f6e\\ ``is_del_extra=True``\\ \u6765\u5220\u9664\u753b\u5e03\u989d\u5916\u591a\u51fa\u7684\u90e8\u5206\u3002\r\n\r\n.. code:: python\r\n\r\n from photo_layout.layout import Canvas, LayoutModel\r\n from photo_layout.image import LayoutImage\r\n\r\n\r\n def main():\r\n canvas = Canvas(width=2000, height=800, color=\"pink\", is_del_extra=True)\r\n layout_model = LayoutModel(canvas=canvas, imagePath=\"test.jpg\", space=10)\r\n layout_image = LayoutImage(layout=layout_model)\r\n image = layout_image.create()\r\n image.show()\r\n\r\n\r\n if __name__ == '__main__':\r\n main()\r\n\r\n\u6548\u679c\u56fe\u5982\u4e0b\uff1a\r\n\r\n.. image:: https://raw.githubusercontent.com/zhenzi0322/photo-layout/master/examples/imgs/example3.jpg\r\n",
"bugtrack_url": null,
"license": "MIT License",
"summary": "Photo Layout",
"version": "1.0.5",
"split_keywords": [
"photo-layout"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "f22c259e09032b1e2639f600c250a551d5069ea868d3eeb0caf38f80b6a7abda",
"md5": "0ce5926cf34756d92df2ebd3022eb138",
"sha256": "a80d33b2172180324bbd345d6b87326f1e356bfa0348ca1f8e43c331fd8e6c75"
},
"downloads": -1,
"filename": "photo_layout-1.0.5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "0ce5926cf34756d92df2ebd3022eb138",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3",
"size": 7950,
"upload_time": "2023-03-17T07:52:16",
"upload_time_iso_8601": "2023-03-17T07:52:16.765293Z",
"url": "https://files.pythonhosted.org/packages/f2/2c/259e09032b1e2639f600c250a551d5069ea868d3eeb0caf38f80b6a7abda/photo_layout-1.0.5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fa720c4291028eaec5162b518d1cf6afc007f1f65fd0700e839adba630e374d7",
"md5": "e25939c398ef5a77faec4978ed5079b3",
"sha256": "0a678c70e61ea49dd8f4cd1b157cf4b23e1662f6e50fdd97bf7ef312f44085f3"
},
"downloads": -1,
"filename": "photo-layout-1.0.5.tar.gz",
"has_sig": false,
"md5_digest": "e25939c398ef5a77faec4978ed5079b3",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3",
"size": 26649,
"upload_time": "2023-03-17T07:52:19",
"upload_time_iso_8601": "2023-03-17T07:52:19.160580Z",
"url": "https://files.pythonhosted.org/packages/fa/72/0c4291028eaec5162b518d1cf6afc007f1f65fd0700e839adba630e374d7/photo-layout-1.0.5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-03-17 07:52:19",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "zhenzi0322",
"github_project": "photo-layout",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "photo-layout"
}