pictureshow


Namepictureshow JSON
Version 0.13.0 PyPI version JSON
download
home_pagehttps://github.com/mportesdev/pictureshow
SummarySave pictures to PDF.
upload_time2024-10-22 10:23:16
maintainerNone
docs_urlNone
authorMichal Porteš
requires_python<4.0,>=3.9
licenseMIT
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            |build-test| |coverage| |bandit| |pre-commit| |release| |pyversions|

Save pictures to PDF from the command line or from your Python programs.


Installation
============

.. code::

    pip install pictureshow


Usage
=====


As a command line tool
----------------------

.. code::

    usage: pictureshow [options] PICTURE [PICTURE ...] -o PATH

    positional arguments:
      PICTURE               one or more input file paths

    options:
      -h, --help            show this help message and exit
      -V, --version         show program's version number and exit
      -q, --quiet           do not print output to stdout
      -v, --verbose         show details of input files skipped due to error
      -F, --fail MODE       control the exit code: 'skipped' exits with code 2 if
                            at least one input file was skipped due to an error;
                            'no-output' (default) exits with code 2 if all files
                            were skipped and no PDF file was saved; 'no' exits
                            with code 0 even if all files were skipped

    output file options:
      -o, --output-file PATH
                            path of the output PDF file (required)
      -f, --force-overwrite
                            save to output file path even if file exists

    page properties options:
      -p, --page-size SIZE  specify page size; default is A4 (available sizes: A0,
                            A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, B0, B1, B2,
                            B3, B4, B5, B6, B7, B8, B9, B10, C0, C1, C2, C3, C4,
                            C5, C6, C7, C8, C9, C10, LETTER, LEGAL,
                            ELEVENSEVENTEEN, JUNIOR_LEGAL, HALF_LETTER,
                            GOV_LETTER, GOV_LEGAL, TABLOID, LEDGER)
      -L, --landscape       set landscape orientation of pages
      -b, --bg-color COLOR  specify page background color as 6-digit hexadecimal
                            RGB, e.g. ff8c00

    picture layout options:
      -l, --layout LAYOUT   specify grid layout (columns x rows) of pictures on
                            page, e.g. 2x3 or 2,3; default is 1x1
      -m, --margin MARGIN   set width of empty space around the cells containing
                            pictures; default is 72 (72 points = 1 inch)
      -s, --stretch-small   scale small pictures up to fit cells
      -c, --fill-cell       fill cells with pictures, ignoring the pictures'
                            aspect ratio


Examples
~~~~~~~~

Save single picture to PDF:

.. code::

    $ pictureshow pics/potato.jpg -o potato.pdf
    .
    Saved 1 picture (1 page) to 'potato.pdf'

Save multiple pictures, four pictures per page (two columns, two rows),
set page orientation to landscape:

.. code::

    $ pictureshow -l 2x2 -L vegetables/* -o vegetables
    ..................................................
    Saved 50 pictures (13 pages) to 'vegetables.pdf'

(Please note that if the output filename has no extension specified,
``.pdf`` will be appended to it. This only applies for the command line tool.)

You can also save pictures from URLs:

.. code::

    $ pictureshow https://cdn.rebrickable.com/media/thumbs/parts/elements/6136555.jpg/250x250p.jpg https://cdn.rebrickable.com/media/thumbs/parts/elements/4119478.jpg/250x250p.jpg -o carrots
    ..
    Saved 2 pictures (2 pages) to 'carrots.pdf'

But please note that this feature is not tested and depends solely on
the underlying reportlab_ backend.


As a Python library
-------------------


Using the ``pictures_to_pdf`` shortcut function
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example:

.. code-block:: python

    from pictureshow import pictures_to_pdf

    pictures_to_pdf(
        'pics/cucumber.jpg',
        'pics/onion.jpg',
        output_file='vegetables.pdf',
    )

The customization parameters of the ``pictures_to_pdf`` function are keyword-only
and their default values correspond to the above shown command line options:

.. code-block:: python

    pictures_to_pdf(
        *pic_files,
        output_file,
        force_overwrite=False,
        page_size='A4',
        landscape=False,
        bg_color=None,
        layout=(1, 1),
        margin=72,
        stretch_small=False,
        fill_cell=False,
    )


Using the ``PictureShow`` class
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Example:

.. code-block:: python

    from pictureshow import PictureShow

    pictures = PictureShow(
        'pics/cucumber.jpg',
        'pics/onion.jpg',
    )
    pictures.save_pdf('vegetables.pdf')

The customization parameters of the ``save_pdf`` method are keyword-only and
their default values correspond to the above shown command line options:

.. code-block:: python

    PictureShow.save_pdf(
        output_file,
        *,
        force_overwrite=False,
        page_size='A4',
        landscape=False,
        bg_color=None,
        layout=(1, 1),
        margin=72,
        stretch_small=False,
        fill_cell=False,
    )


.. |build-test| image:: https://github.com/mportesdev/pictureshow/actions/workflows/build-test.yml/badge.svg
    :target: https://github.com/mportesdev/pictureshow/actions
.. |coverage| image:: https://img.shields.io/codecov/c/gh/mportesdev/pictureshow
    :target: https://codecov.io/gh/mportesdev/pictureshow
.. |bandit| image:: https://img.shields.io/badge/security-bandit-yellow.svg
    :target: https://github.com/PyCQA/bandit
.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit
    :target: https://github.com/pre-commit/pre-commit
.. |release| image:: https://img.shields.io/github/v/release/mportesdev/pictureshow
    :target: https://github.com/mportesdev/pictureshow/releases/latest
.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pictureshow
    :target: https://pypi.org/project/pictureshow
.. _reportlab: https://pypi.org/project/reportlab


            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mportesdev/pictureshow",
    "name": "pictureshow",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Michal Porte\u0161",
    "author_email": "michalportes1@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6c/8b/1a51ea7bef7e95b961e3f319df5032feffdd9dbbe98498033ab7cb5ea0dd/pictureshow-0.13.0.tar.gz",
    "platform": null,
    "description": "|build-test| |coverage| |bandit| |pre-commit| |release| |pyversions|\n\nSave pictures to PDF from the command line or from your Python programs.\n\n\nInstallation\n============\n\n.. code::\n\n    pip install pictureshow\n\n\nUsage\n=====\n\n\nAs a command line tool\n----------------------\n\n.. code::\n\n    usage: pictureshow [options] PICTURE [PICTURE ...] -o PATH\n\n    positional arguments:\n      PICTURE               one or more input file paths\n\n    options:\n      -h, --help            show this help message and exit\n      -V, --version         show program's version number and exit\n      -q, --quiet           do not print output to stdout\n      -v, --verbose         show details of input files skipped due to error\n      -F, --fail MODE       control the exit code: 'skipped' exits with code 2 if\n                            at least one input file was skipped due to an error;\n                            'no-output' (default) exits with code 2 if all files\n                            were skipped and no PDF file was saved; 'no' exits\n                            with code 0 even if all files were skipped\n\n    output file options:\n      -o, --output-file PATH\n                            path of the output PDF file (required)\n      -f, --force-overwrite\n                            save to output file path even if file exists\n\n    page properties options:\n      -p, --page-size SIZE  specify page size; default is A4 (available sizes: A0,\n                            A1, A2, A3, A4, A5, A6, A7, A8, A9, A10, B0, B1, B2,\n                            B3, B4, B5, B6, B7, B8, B9, B10, C0, C1, C2, C3, C4,\n                            C5, C6, C7, C8, C9, C10, LETTER, LEGAL,\n                            ELEVENSEVENTEEN, JUNIOR_LEGAL, HALF_LETTER,\n                            GOV_LETTER, GOV_LEGAL, TABLOID, LEDGER)\n      -L, --landscape       set landscape orientation of pages\n      -b, --bg-color COLOR  specify page background color as 6-digit hexadecimal\n                            RGB, e.g. ff8c00\n\n    picture layout options:\n      -l, --layout LAYOUT   specify grid layout (columns x rows) of pictures on\n                            page, e.g. 2x3 or 2,3; default is 1x1\n      -m, --margin MARGIN   set width of empty space around the cells containing\n                            pictures; default is 72 (72 points = 1 inch)\n      -s, --stretch-small   scale small pictures up to fit cells\n      -c, --fill-cell       fill cells with pictures, ignoring the pictures'\n                            aspect ratio\n\n\nExamples\n~~~~~~~~\n\nSave single picture to PDF:\n\n.. code::\n\n    $ pictureshow pics/potato.jpg -o potato.pdf\n    .\n    Saved 1 picture (1 page) to 'potato.pdf'\n\nSave multiple pictures, four pictures per page (two columns, two rows),\nset page orientation to landscape:\n\n.. code::\n\n    $ pictureshow -l 2x2 -L vegetables/* -o vegetables\n    ..................................................\n    Saved 50 pictures (13 pages) to 'vegetables.pdf'\n\n(Please note that if the output filename has no extension specified,\n``.pdf`` will be appended to it. This only applies for the command line tool.)\n\nYou can also save pictures from URLs:\n\n.. code::\n\n    $ pictureshow https://cdn.rebrickable.com/media/thumbs/parts/elements/6136555.jpg/250x250p.jpg https://cdn.rebrickable.com/media/thumbs/parts/elements/4119478.jpg/250x250p.jpg -o carrots\n    ..\n    Saved 2 pictures (2 pages) to 'carrots.pdf'\n\nBut please note that this feature is not tested and depends solely on\nthe underlying reportlab_ backend.\n\n\nAs a Python library\n-------------------\n\n\nUsing the ``pictures_to_pdf`` shortcut function\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nExample:\n\n.. code-block:: python\n\n    from pictureshow import pictures_to_pdf\n\n    pictures_to_pdf(\n        'pics/cucumber.jpg',\n        'pics/onion.jpg',\n        output_file='vegetables.pdf',\n    )\n\nThe customization parameters of the ``pictures_to_pdf`` function are keyword-only\nand their default values correspond to the above shown command line options:\n\n.. code-block:: python\n\n    pictures_to_pdf(\n        *pic_files,\n        output_file,\n        force_overwrite=False,\n        page_size='A4',\n        landscape=False,\n        bg_color=None,\n        layout=(1, 1),\n        margin=72,\n        stretch_small=False,\n        fill_cell=False,\n    )\n\n\nUsing the ``PictureShow`` class\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nExample:\n\n.. code-block:: python\n\n    from pictureshow import PictureShow\n\n    pictures = PictureShow(\n        'pics/cucumber.jpg',\n        'pics/onion.jpg',\n    )\n    pictures.save_pdf('vegetables.pdf')\n\nThe customization parameters of the ``save_pdf`` method are keyword-only and\ntheir default values correspond to the above shown command line options:\n\n.. code-block:: python\n\n    PictureShow.save_pdf(\n        output_file,\n        *,\n        force_overwrite=False,\n        page_size='A4',\n        landscape=False,\n        bg_color=None,\n        layout=(1, 1),\n        margin=72,\n        stretch_small=False,\n        fill_cell=False,\n    )\n\n\n.. |build-test| image:: https://github.com/mportesdev/pictureshow/actions/workflows/build-test.yml/badge.svg\n    :target: https://github.com/mportesdev/pictureshow/actions\n.. |coverage| image:: https://img.shields.io/codecov/c/gh/mportesdev/pictureshow\n    :target: https://codecov.io/gh/mportesdev/pictureshow\n.. |bandit| image:: https://img.shields.io/badge/security-bandit-yellow.svg\n    :target: https://github.com/PyCQA/bandit\n.. |pre-commit| image:: https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit\n    :target: https://github.com/pre-commit/pre-commit\n.. |release| image:: https://img.shields.io/github/v/release/mportesdev/pictureshow\n    :target: https://github.com/mportesdev/pictureshow/releases/latest\n.. |pyversions| image:: https://img.shields.io/pypi/pyversions/pictureshow\n    :target: https://pypi.org/project/pictureshow\n.. _reportlab: https://pypi.org/project/reportlab\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Save pictures to PDF.",
    "version": "0.13.0",
    "project_urls": {
        "Homepage": "https://github.com/mportesdev/pictureshow"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6dee09a05df223a8b5afb119df1bd32543c232c3dae3ea9dc0266e546334983f",
                "md5": "201505905742bd1f78c614c3750ec870",
                "sha256": "2c0baec73a1b576fd06260a0c75829857fd23200476e0a802d2649ab8e56df73"
            },
            "downloads": -1,
            "filename": "pictureshow-0.13.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "201505905742bd1f78c614c3750ec870",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.9",
            "size": 10357,
            "upload_time": "2024-10-22T10:23:15",
            "upload_time_iso_8601": "2024-10-22T10:23:15.213900Z",
            "url": "https://files.pythonhosted.org/packages/6d/ee/09a05df223a8b5afb119df1bd32543c232c3dae3ea9dc0266e546334983f/pictureshow-0.13.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6c8b1a51ea7bef7e95b961e3f319df5032feffdd9dbbe98498033ab7cb5ea0dd",
                "md5": "d449c0878561928456646928b79c5c7b",
                "sha256": "0825dcfdb6acf3538ac8d442fb9a2e242c95faf6fb31682421f30c7b5ffbbaea"
            },
            "downloads": -1,
            "filename": "pictureshow-0.13.0.tar.gz",
            "has_sig": false,
            "md5_digest": "d449c0878561928456646928b79c5c7b",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.9",
            "size": 9617,
            "upload_time": "2024-10-22T10:23:16",
            "upload_time_iso_8601": "2024-10-22T10:23:16.415486Z",
            "url": "https://files.pythonhosted.org/packages/6c/8b/1a51ea7bef7e95b961e3f319df5032feffdd9dbbe98498033ab7cb5ea0dd/pictureshow-0.13.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-22 10:23:16",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mportesdev",
    "github_project": "pictureshow",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pictureshow"
}
        
Elapsed time: 0.54327s