diff options
author | Johannes 'josch' Schauer <josch@debian.org> | 2018-07-20 07:21:40 +0200 |
---|---|---|
committer | Johannes 'josch' Schauer <josch@debian.org> | 2018-07-20 07:21:40 +0200 |
commit | aa564ac57de87724808ae3c2c6baf92688d181cc (patch) | |
tree | ffa2a656b8a0935220ae295a95971e0d97576daf /PKG-INFO | |
parent | 20da8c12b9524ea6d405cf12df5a2f426b60b4c5 (diff) |
Import upstream version 0.3.0
Diffstat (limited to 'PKG-INFO')
-rw-r--r-- | PKG-INFO | 106 |
1 files changed, 68 insertions, 38 deletions
@@ -1,43 +1,46 @@ Metadata-Version: 1.1 Name: img2pdf -Version: 0.2.3 +Version: 0.3.0 Summary: Convert images to PDF via direct JPEG inclusion. Home-page: https://gitlab.mister-muffin.de/josch/img2pdf Author: Johannes 'josch' Schauer Author-email: josch@mister-muffin.de License: LGPL -Download-URL: https://gitlab.mister-muffin.de/josch/img2pdf/repository/archive.tar.gz?ref=0.2.3 +Download-URL: https://gitlab.mister-muffin.de/josch/img2pdf/repository/archive.tar.gz?ref=0.3.0 +Description-Content-Type: UNKNOWN Description: img2pdf ======= Losslessly convert raster images to PDF. The file size will not unnecessarily - increase. One major application would be a number of scans made in JPEG format - which should now become part of a single PDF document. Existing solutions - would either re-encode the input JPEG files (leading to quality loss) or store - them in the zip/flate format which results into the PDF becoming unnecessarily - large in terms of its file size. + increase. It can for example be used to create a PDF document from a number of + scans that are only available in JPEG format. Existing solutions would either + re-encode the input JPEG files (leading to quality loss) or store them in the + zip/flate format which results into the PDF becoming unnecessarily large in + terms of its file size. Background ---------- - Quality loss can be avoided when converting JPEG and JPEG2000 images to PDF by - embedding them without re-encoding. I wrote this piece of python code. - because I was missing a tool to do this automatically. Img2pdf basically just - wraps JPEG images into the PDF container as they are. + Quality loss can be avoided when converting PNG, JPEG and JPEG2000 images to + PDF by embedding them into the PDF without re-encoding them. This is what + img2pdf does. It thus treats the PDF format merely as a container format for + storing one or more JPEGs or PNGs without re-encoding the images themselves. - If you know an existing tool which allows one to embed JPEG and JPEG2000 images - into a PDF container without recompression, please contact me so that I can put - this code into the garbage bin. + If you know an existing tool which allows one to embed PNG, JPEG and JPEG2000 + images into a PDF container without recompression, please contact me so that I + can put this code into the garbage bin. Functionality ------------- - This program will take a list of images and produce a PDF file with the images - embedded in it. JPEG and JPEG2000 images will be included without - recompression. Raster images in other formats will be included with zip/flate - encoding which usually leads to an increase in the resulting size because - formats like png compress better than PDF which just zip/flate compresses the - RGB data. As a result, this tool is able to losslessly wrap images into a PDF + This program will take a list of raster images and produce a PDF file with the + images embedded in it. PNG, JPEG and JPEG2000 images will be included without + recompression and the resulting PDF will only be slightly larger than the input + images due to the overhead of the PDF container. Raster images in other + formats (like gif or tif) will be included using the lossless zip/flate + encoding using the PNG Paeth predictor. + + As a result, this tool is able to losslessly wrap raster images into a PDF container with a quality to filesize ratio that is typically better (in case of JPEG and JPEG2000 images) or equal (in case of other formats) than that of existing tools. @@ -61,13 +64,17 @@ Description: img2pdf However, this approach will result in PDF files that are a few times larger than the input JPEG or JPEG2000 file. - img2pdf is able to losslessly embed JPEG and JPEG2000 files into a PDF + Furthermore, when converting PNG images, popular tools like imagemagick use + flate encoding without a predictor. This means, that image file size ends up + being several orders of magnitude larger then necessary. + + img2pdf is able to losslessly embed PNG, JPEG and JPEG2000 files into a PDF container without additional overhead (aside from the PDF structure itself), save other graphics formats using lossless zip compression, and produce multi-page PDF files when more than one input image is given. - Also, since JPEG and JPEG2000 images are not reencoded, conversion with img2pdf - is several times faster than with other tools. + Also, since PNG, JPEG and JPEG2000 images are not reencoded, conversion with + img2pdf is several times faster than with other tools. Usage ----- @@ -76,7 +83,9 @@ Description: img2pdf descriptor. If no output file is specified with the `-o`/`--output` option, output will be - done to stdout. + done to stdout. A typical invocation is: + + img2pdf img1.png img2.jpg -o out.pdf The detailed documentation can be accessed by running: @@ -89,14 +98,6 @@ Description: img2pdf If you find a JPEG or JPEG2000 file that, when embedded cannot be read by the Adobe Acrobat Reader, please contact me. - For lossless conversion of formats other than JPEG or JPEG2000, zip/flate - encoding is used. This choice is based on tests I did with a number of images. - I converted them into PDF using the lossless variants of the compression - formats offered by imagemagick. In all my tests, zip/flate encoding performed - best. You can verify my findings using the test_comp.sh script with any input - image given as a commandline argument. If you find an input file that is - outperformed by another lossless compression method, contact me. - I have not yet figured out how to determine the colorspace of JPEG2000 files. Therefore JPEG2000 files use DeviceRGB by default. For JPEG2000 files with other colorspaces, you must explicitly specify it using the `--colorspace` @@ -123,19 +124,19 @@ Description: img2pdf You can then install the package using: - $ pip install img2pdf + $ pip3 install img2pdf If you prefer to install from source code use: $ cd img2pdf/ - $ pip install . + $ pip3 install . To test the console script without installing the package on your system, use virtualenv: $ cd img2pdf/ $ virtualenv ve - $ ve/bin/pip install . + $ ve/bin/pip3 install . You can then test the converter using: @@ -144,10 +145,36 @@ Description: img2pdf The package can also be used as a library: import img2pdf - pdf_bytes = img2pdf.convert('test.jpg') - file = open("name.pdf","wb") - file.write(pdf_bytes) + # opening from filename + with open("name.pdf","wb") as f: + f.write(img2pdf.convert('test.jpg')) + + # opening from file handle + with open("name.pdf","wb") as f1, open("test.jpg") as f2: + f1.write(img2pdf.convert(f2)) + + # using in-memory image data + with open("name.pdf","wb") as f: + f.write(img2pdf.convert("\x89PNG...") + + # multiple inputs (variant 1) + with open("name.pdf","wb") as f: + f.write(img2pdf.convert("test1.jpg", "test2.png")) + + # multiple inputs (variant 2) + with open("name.pdf","wb") as f: + f.write(img2pdf.convert(["test1.jpg", "test2.png"])) + + # writing to file descriptor + with open("name.pdf","wb") as f1, open("test.jpg") as f2: + img2pdf.convert(f2, outputstream=f1) + + # specify paper size (A4) + a4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297)) + layout_fun = img2pdf.get_layout_fun(a4inpt) + with open("name.pdf","wb") as f: + f.write(img2pdf.convert('test.jpg', layout_fun=layout_fun)) Keywords: jpeg pdf converter Platform: UNKNOWN @@ -156,9 +183,12 @@ Classifier: Intended Audience :: Developers Classifier: Intended Audience :: Other Audience Classifier: Environment :: Console Classifier: Programming Language :: Python +Classifier: Programming Language :: Python :: 2 +Classifier: Programming Language :: Python :: 2.7 Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3.5 Classifier: Programming Language :: Python :: Implementation :: CPython +Classifier: Programming Language :: Python :: Implementation :: PyPy Classifier: License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3) Classifier: Natural Language :: English Classifier: Operating System :: OS Independent |