Save pictures to PDF
Project description
Save pictures to PDF from the command line or from your Python programs.
Requirements
Python 3.6 or higher is required. The only third-party dependency is reportlab.
Installation
pip install pictureshow
As a command line tool
Usage:
usage: pictureshow [-h] [-p SIZE] [-L] [-m MARGIN] [-l LAYOUT] [-s] [-f]
[-q | -v] [-V]
PIC [PIC ...] PDF
positional arguments:
PIC one or more input picture file paths
PDF target PDF file path
optional arguments:
-h, --help show this help message and exit
-p SIZE, --page-size SIZE
specify page size; default is A4
-L, --landscape force landscape orientation of page
-m MARGIN, --margin MARGIN
set width of empty space around pictures; default is
72 (72 points = 1 inch)
-l LAYOUT, --layout LAYOUT
specify grid layout of pictures on page, e.g. 2x3 or
2,3; default is 1x1
-s, --stretch-small scale small pictures up to fit drawing area
-f, --force-overwrite
save target file even if filename exists
-q, --quiet suppress printing to stdout
-v, --verbose provide details on files skipped due to error
-V, --version show program's version number and exit
Example 1
Save a single picture to PDF.
$ pictureshow pics/mandelbrot.png mandelbrot.pdf
Saved 1 picture (1 page) to '/.../mandelbrot.pdf'
Example 2
Select pictures using a glob pattern [1], set page to landscape Letter-sized [2].
$ pictureshow pics/plots/gauss* gauss.pdf --landscape --page-size=LETTER
Saved 2 pictures (2 pages) to '/.../gauss.pdf'
Example 3
Select pictures using a glob pattern, set half-inch margin and layout of 1x3 pictures per page.
$ pictureshow -m36 -l1x3 pics/blender/* 3d_pics.pdf
Saved 4 pictures (2 pages) to '/.../3d_pics.pdf'
As a Python library
Using the PictureShow class:
from pictureshow import PictureShow
pic_show = PictureShow('pics/mandelbrot.png', 'pics/mandelbrot.jpg')
pic_show.save_pdf('pictures.pdf')
Using the pictures_to_pdf shortcut function:
from pictureshow import pictures_to_pdf
list_of_pictures = ['pics/mandelbrot.png', 'pics/mandelbrot.jpg']
pictures_to_pdf(*list_of_pictures, pdf_file='pictures.pdf')
Please note that unlike the command line interface, pdf_file must be specified as a keyword argument.
Another example, demonstrating all available keyword-only arguments:
from pathlib import Path
from pictureshow import pictures_to_pdf
list_of_pictures = sorted(Path.cwd().glob('pics/blender/*'))
pictures_to_pdf(
*list_of_pictures,
pdf_file='3d_pics.pdf',
page_size='A5',
landscape=True,
margin=18,
layout=(3, 3),
stretch_small=True,
force_overwrite=True
)
Footnotes
Project details
Release history Release notifications | RSS feed
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 Distribution
Close
Hashes for pictureshow-0.6.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5303f0ee15f199b2359fd5d84302497a8b3572c6da571c2082ceea5afb6234c3 |
|
MD5 | ebcba821f9e75881d0896a94dda39c6e |
|
BLAKE2b-256 | c751230145b1824abbb68b5a0d7c291927a2ea852e88be99e9d784f13a701c60 |