{ "info": { "author": "Johannes 'josch' Schauer", "author_email": "josch@mister-muffin.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "Intended Audience :: Other Audience", "License :: OSI Approved :: GNU Lesser General Public License v3 (LGPLv3)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "img2pdf\n=======\n\nLossless conversion of raster images to PDF. You should use img2pdf if your\npriorities are (in this order):\n\n 1. **always lossless**: the image embedded in the PDF will always have the\n exact same color information for every pixel as the input\n 2. **small**: if possible, the difference in filesize between the input image\n and the output PDF will only be the overhead of the PDF container itself\n 3. **fast**: if possible, the input image is just pasted into the PDF document\n as-is without any CPU hungry re-encoding of the pixel data\n\nConventional conversion software (like ImageMagick) would either:\n\n 1. not be lossless because lossy re-encoding to JPEG\n 2. not be small because using wasteful flate encoding of raw pixel data\n 3. not be fast because input data gets re-encoded\n\nAnother advantage of not having to re-encode the input (in most common\nsituations) is, that img2pdf is able to handle much larger input than other\nsoftware, because the raw pixel data never has to be loaded into memory.\n\nThe following table shows how img2pdf handles different input depending on the\ninput file format and image color space.\n\n| Format | Colorspace | Result |\n| -------------------- | ------------------------------ | ------------- |\n| JPEG | any | direct |\n| JPEG2000 | any | direct |\n| PNG (non-interlaced) | any | direct |\n| TIFF (CCITT Group 4) | monochrome | direct |\n| any | any except CMYK and monochrome | PNG Paeth |\n| any | monochrome | CCITT Group 4 |\n| any | CMYK | flate |\n\nFor JPEG, JPEG2000, non-interlaced PNG and TIFF images with CCITT Group 4\nencoded data, img2pdf directly embeds the image data into the PDF without\nre-encoding it. It thus treats the PDF format merely as a container format for\nthe image data. In these cases, img2pdf only increases the filesize by the size\nof the PDF container (typically around 500 to 700 bytes). Since data is only\ncopied and not re-encoded, img2pdf is also typically faster than other\nsolutions for these input formats.\n\nFor all other input types, img2pdf first has to transform the pixel data to\nmake it compatible with PDF. In most cases, the PNG Paeth filter is applied to\nthe pixel data. For monochrome input, CCITT Group 4 is used instead. Only for\nCMYK input no filter is applied before finally applying flate compression.\n\nUsage\n-----\n\nThe images must be provided as files because img2pdf needs to seek in the file\ndescriptor.\n\nIf no output file is specified with the `-o`/`--output` option, output will be\ndone to stdout. A typical invocation is:\n\n\t$ img2pdf img1.png img2.jpg -o out.pdf\n\nThe detailed documentation can be accessed by running:\n\n\t$ img2pdf --help\n\nBugs\n----\n\n - If you find a JPEG, JPEG2000, PNG or CCITT Group 4 encoded TIFF file that,\n when embedded into the PDF cannot be read by the Adobe Acrobat Reader,\n please contact me.\n\n - I have not yet figured out how to determine the colorspace of JPEG2000\n files. Therefore JPEG2000 files use DeviceRGB by default. For JPEG2000\n files with other colorspaces, you must explicitly specify it using the\n `--colorspace` option.\n\n - Input images with alpha channels are not allowed. PDF doesn't support alpha\n channels in images and thus, the alpha channel of the input would have to be\n discarded. But img2pdf will always be lossless and thus, input images must\n not carry transparency information.\n\n - img2pdf uses PIL (or Pillow) to obtain image meta data and to convert the\n input if necessary. To prevent decompression bomb denial of service attacks,\n Pillow limits the maximum number of pixels an input image is allowed to\n have. If you are sure that you know what you are doing, then you can disable\n this safeguard by passing the `--pillow-limit-break` option to img2pdf. This\n allows one to process even very large input images.\n\nInstallation\n------------\n\nOn a Debian- and Ubuntu-based systems, img2pdf can be installed from the\nofficial repositories:\n\n\t$ apt install img2pdf\n\nIf you want to install it using pip, you can run:\n\n\t$ pip3 install img2pdf\n\nIf you prefer to install from source code use:\n\n\t$ cd img2pdf/\n\t$ pip3 install .\n\nTo test the console script without installing the package on your system,\nuse virtualenv:\n\n\t$ cd img2pdf/\n\t$ virtualenv ve\n\t$ ve/bin/pip3 install .\n\nYou can then test the converter using:\n\n\t$ ve/bin/img2pdf -o test.pdf src/tests/test.jpg\n\nThe package can also be used as a library:\n\n\timport img2pdf\n\n\t# opening from filename\n\twith open(\"name.pdf\",\"wb\") as f:\n\t\tf.write(img2pdf.convert('test.jpg'))\n\n\t# opening from file handle\n\twith open(\"name.pdf\",\"wb\") as f1, open(\"test.jpg\") as f2:\n\t\tf1.write(img2pdf.convert(f2))\n\n\t# using in-memory image data\n\twith open(\"name.pdf\",\"wb\") as f:\n\t\tf.write(img2pdf.convert(\"\\x89PNG...\")\n\n\t# multiple inputs (variant 1)\n\twith open(\"name.pdf\",\"wb\") as f:\n\t\tf.write(img2pdf.convert(\"test1.jpg\", \"test2.png\"))\n\n\t# multiple inputs (variant 2)\n\twith open(\"name.pdf\",\"wb\") as f:\n\t\tf.write(img2pdf.convert([\"test1.jpg\", \"test2.png\"]))\n\n\t# writing to file descriptor\n\twith open(\"name.pdf\",\"wb\") as f1, open(\"test.jpg\") as f2:\n\t\timg2pdf.convert(f2, outputstream=f1)\n\n\t# specify paper size (A4)\n\ta4inpt = (img2pdf.mm_to_pt(210),img2pdf.mm_to_pt(297))\n\tlayout_fun = img2pdf.get_layout_fun(a4inpt)\n\twith open(\"name.pdf\",\"wb\") as f:\n\t\tf.write(img2pdf.convert('test.jpg', layout_fun=layout_fun))\n\nComparison to ImageMagick\n-------------------------\n\nCreate a large test image:\n\n\t$ convert logo: -resize 8000x original.jpg\n\nConvert it into PDF using ImageMagick and img2pdf:\n\n\t$ time img2pdf original.jpg -o img2pdf.pdf\n\t$ time convert original.jpg imagemagick.pdf\n\nNotice how ImageMagick took an order of magnitude longer to do the conversion\nthan img2pdf. It also used twice the memory.\n\nNow extract the image data from both PDF documents and compare it to the\noriginal:\n\n\t$ pdfimages -all img2pdf.pdf tmp\n\t$ compare -metric AE original.jpg tmp-000.jpg null:\n\t0\n\t$ pdfimages -all imagemagick.pdf tmp\n\t$ compare -metric AE original.jpg tmp-000.jpg null:\n\t118716\n\nTo get lossless output with ImageMagick we can use Zip compression but that\nunnecessarily increases the size of the output:\n\n\t$ convert original.jpg -compress Zip imagemagick.pdf\n\t$ pdfimages -all imagemagick.pdf tmp\n\t$ compare -metric AE original.jpg tmp-000.png null:\n\t0\n\t$ stat --format=\"%s %n\" original.jpg img2pdf.pdf imagemagick.pdf\n\t1535837 original.jpg\n\t1536683 img2pdf.pdf\n\t9397809 imagemagick.pdf\n\nComparison to pdfLaTeX\n----------------------\n\npdfLaTeX performs a lossless conversion from included images to PDF by default.\nIf the input is a JPEG, then it simply embeds the JPEG into the PDF in the same\nway as img2pdf does it. But for other image formats it uses flate compression\nof the plain pixel data and thus needlessly increases the output file size:\n\n\t$ convert logo: -resize 8000x original.png\n\t$ cat << END > pdflatex.tex\n\t\\documentclass{article}\n\t\\usepackage{graphicx}\n\t\\begin{document}\n\t\\includegraphics{original.png}\n\t\\end{document}\n\tEND\n\t$ pdflatex pdflatex.tex\n\t$ stat --format=\"%s %n\" original.png pdflatex.pdf\n\t4500182 original.png\n\t9318120 pdflatex.pdf\n\nComparison to Tesseract OCR\n---------------------------\n\nTesseract OCR comes closest to the functionality img2pdf provides. It is able\nto convert JPEG and PNG input to PDF without needlessly increasing the filesize\nand is at the same time lossless. So if your input is JPEG and PNG images, then\nyou should safely be able to use Tesseract instead of img2pdf. For other input,\nTesseract might not do a lossless conversion. For example it converts CMYK\ninput to RGB and removes the alpha channel from images with transparency. For\nmultipage TIFF or animated GIF, it will only convert the first frame.", "description_content_type": "", "docs_url": null, "download_url": "https://gitlab.mister-muffin.de/josch/img2pdf/repository/archive.tar.gz?ref=0.3.3", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://gitlab.mister-muffin.de/josch/img2pdf", "keywords": "jpeg pdf converter", "license": "LGPL", "maintainer": "", "maintainer_email": "", "name": "img2pdf", "package_url": "https://pypi.org/project/img2pdf/", "platform": "", "project_url": "https://pypi.org/project/img2pdf/", "project_urls": { "Download": "https://gitlab.mister-muffin.de/josch/img2pdf/repository/archive.tar.gz?ref=0.3.3", "Homepage": "https://gitlab.mister-muffin.de/josch/img2pdf" }, "release_url": "https://pypi.org/project/img2pdf/0.3.3/", "requires_dist": null, "requires_python": "", "summary": "Convert images to PDF via direct JPEG inclusion.", "version": "0.3.3" }, "last_serial": 4667965, "releases": { "0.1.2": [ { "comment_text": "", "digests": { "md5": "a18b5ec226617bbc8c98cbc7582f831b", "sha256": "82c2f409cd8a259eb1ce874124210fe2c2744ac51ba25184f1a07973ae275556" }, "downloads": -1, "filename": "img2pdf-0.1.2.tar.gz", "has_sig": false, "md5_digest": "a18b5ec226617bbc8c98cbc7582f831b", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14832, "upload_time": "2014-09-07T06:01:29", "url": "https://files.pythonhosted.org/packages/aa/3d/aff1adc653c7ba73e229cb16cc3f6a2be8a2a2af6331af991f7e6df8df18/img2pdf-0.1.2.tar.gz" } ], "0.1.3": [ { "comment_text": "", "digests": { "md5": "8987d8743c0b1851b87d8808bfe87272", "sha256": "cecf84aaeee8f138baaa017a49c48832c1358a333189b7491d8ccbcb76ab7351" }, "downloads": -1, "filename": "img2pdf-0.1.3.tar.gz", "has_sig": false, "md5_digest": "8987d8743c0b1851b87d8808bfe87272", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14937, "upload_time": "2014-11-10T09:17:27", "url": "https://files.pythonhosted.org/packages/94/73/1ca19d8112aa609c023af263263a991935f3b3d67642bdb9819ae4d3a432/img2pdf-0.1.3.tar.gz" } ], "0.1.4": [ { "comment_text": "", "digests": { "md5": "e71026eda0dc2972960c33740c56728a", "sha256": "ff9d7e681523f2e3d8230d0a9a824265879f62094d889c8bf38947922ea6f470" }, "downloads": -1, "filename": "img2pdf-0.1.4.tar.gz", "has_sig": false, "md5_digest": "e71026eda0dc2972960c33740c56728a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 15139, "upload_time": "2015-01-21T10:09:10", "url": "https://files.pythonhosted.org/packages/7c/23/82db54993425e388d849eb4ef11de970dcb1a7281691bb155e21f17c44df/img2pdf-0.1.4.tar.gz" } ], "0.1.5": [ { "comment_text": "", "digests": { "md5": "8fff0636a17d5eb68ab38f73515f2f24", "sha256": "20b0bea4e54a8337e2ca032015a145501c56be89078c63e29f115d90b2efba54" }, "downloads": -1, "filename": "img2pdf-0.1.5.tar.gz", "has_sig": false, "md5_digest": "8fff0636a17d5eb68ab38f73515f2f24", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 23644, "upload_time": "2015-02-16T18:40:49", "url": "https://files.pythonhosted.org/packages/fc/b8/7f3f336f1b1f86e02ae1a4cbfff267bf0d567b6b040c43f8587e43aa1d8d/img2pdf-0.1.5.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "e42e785c161605bccd78d29097537671", "sha256": "ee66783fa97440f587aef662119b1014b704feff8c783e9e29412998c42ef70c" }, "downloads": -1, "filename": "img2pdf-0.2.tar.gz", "has_sig": false, "md5_digest": "e42e785c161605bccd78d29097537671", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 44648, "upload_time": "2016-02-02T18:52:37", "url": "https://files.pythonhosted.org/packages/ec/e3/ed6dbcb6edb941709efad5b54a57c15107b1484fb4a55725afaf86f776e8/img2pdf-0.2.tar.gz" } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "19c187ba34a8762be8b044612d4cd19d", "sha256": "11bf6ae5cce133249cb8fe0638fd1a7dbf22c5291a2a136ea715fb2fe4cf10f0" }, "downloads": -1, "filename": "img2pdf-0.2.1.tar.gz", "has_sig": false, "md5_digest": "19c187ba34a8762be8b044612d4cd19d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 46219, "upload_time": "2016-07-12T04:29:14", "url": "https://files.pythonhosted.org/packages/8b/fa/a69becbc9b2f1c5eff52ae1dc4d7394de239729be252e8ff6a50a21c0a4d/img2pdf-0.2.1.tar.gz" } ], "0.2.3": [ { "comment_text": "", "digests": { "md5": "f5d75e04d61c3bbc68e193c9138fd3d3", "sha256": "156d9abae0429e30d68c8c8978fbcc23d5a841c6aa8bb914755c5b366f95dc46" }, "downloads": -1, "filename": "img2pdf-0.2.3.tar.gz", "has_sig": false, "md5_digest": "f5d75e04d61c3bbc68e193c9138fd3d3", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 48174, "upload_time": "2017-01-20T04:47:25", "url": "https://files.pythonhosted.org/packages/b6/bc/e72a813265a5e7b7319c74130888c60bed441b4a13c2b8f76a33c19541bb/img2pdf-0.2.3.tar.gz" } ], "0.2.4": [ { "comment_text": "", "digests": { "md5": "bc8fca44a80af45e90f72d6b9003f5e1", "sha256": "140b70fa3a3bfb54e92947818cee01483a4f1492b5d1d02b0f649257f5ffc9ae" }, "downloads": -1, "filename": "img2pdf-0.2.4.tar.gz", "has_sig": false, "md5_digest": "bc8fca44a80af45e90f72d6b9003f5e1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 54426, "upload_time": "2017-05-23T15:56:32", "url": "https://files.pythonhosted.org/packages/7e/a2/4f06081f674920be757d894b4bab874e6a3b5227e730cb7618430b366e69/img2pdf-0.2.4.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "635613eeca0bf31869235a641ad14f45", "sha256": "49d78207f1c727fdad5b647f60dc57fb977a378d51f271db6fa8e45c945d14fa" }, "downloads": -1, "filename": "img2pdf-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "635613eeca0bf31869235a641ad14f45", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 29416, "upload_time": "2018-07-18T09:37:23", "url": "https://files.pythonhosted.org/packages/0a/69/e4fd5fa2226a0b15710ab39c18ad3699f8c7aa2c1c38e92e3fd960d8c412/img2pdf-0.3.0-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "d4ec3890abfccf9e49535953449be274", "sha256": "8d81bb05abfe73172a31afced1019e7636aaddd13a75207daef032350cec21fc" }, "downloads": -1, "filename": "img2pdf-0.3.0.tar.gz", "has_sig": false, "md5_digest": "d4ec3890abfccf9e49535953449be274", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 63646, "upload_time": "2018-07-18T09:37:24", "url": "https://files.pythonhosted.org/packages/a6/5a/410a05ebefe60885dd8a13e18b82692d23bbf0fc74f2807b0ae3e7c6bfb1/img2pdf-0.3.0.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "fa727c12eff4fe40f63aa5ac9f162dca", "sha256": "626a7b1560379a379acaec9966f52de034fa84e2f51871783d4b331961f7e0d2" }, "downloads": -1, "filename": "img2pdf-0.3.1-py3-none-any.whl", "has_sig": true, "md5_digest": "fa727c12eff4fe40f63aa5ac9f162dca", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 31307, "upload_time": "2018-08-04T13:45:23", "url": "https://files.pythonhosted.org/packages/fb/d8/59102a6f8337d7b92043396a3ee8a9deebfc329268423f2a48230666a944/img2pdf-0.3.1-py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "86fe65930a4e2e07694f63cbb7defdb6", "sha256": "4409c12293eca94fdcd8e0da1ad2392b6ee3adfcedf438bb8b685924dc1b3a1c" }, "downloads": -1, "filename": "img2pdf-0.3.1.tar.gz", "has_sig": true, "md5_digest": "86fe65930a4e2e07694f63cbb7defdb6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 67954, "upload_time": "2018-08-04T13:45:24", "url": "https://files.pythonhosted.org/packages/3e/40/aa7b63857908566b76d1849065a700248b088bf502c244e839fa2548d99e/img2pdf-0.3.1.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "2fe4b914f4455e17b7a7b8bd41a24f43", "sha256": "28eaf39e90997979893c4e64be5b23c8fbb1122688a28df127c957388b7d9d1f" }, "downloads": -1, "filename": "img2pdf-0.3.2.tar.gz", "has_sig": false, "md5_digest": "2fe4b914f4455e17b7a7b8bd41a24f43", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 71483, "upload_time": "2018-11-20T15:40:53", "url": "https://files.pythonhosted.org/packages/56/1e/675f153521e727b7e30da26bb4a76b9730711cbb664b2338e349aef1ce4c/img2pdf-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "211c7bfacebbccccffe47f5b732921a5", "sha256": "9d77c17ee65a736abe92ef8cba9cca009c064ea4ed74492c01aea596e41856cf" }, "downloads": -1, "filename": "img2pdf-0.3.3.tar.gz", "has_sig": true, "md5_digest": "211c7bfacebbccccffe47f5b732921a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 80523, "upload_time": "2019-01-07T09:45:05", "url": "https://files.pythonhosted.org/packages/e0/c6/7cd14232a1b10bf884c12daf3626afb76c4f60b52ae0eb23ce1519542ae4/img2pdf-0.3.3.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "211c7bfacebbccccffe47f5b732921a5", "sha256": "9d77c17ee65a736abe92ef8cba9cca009c064ea4ed74492c01aea596e41856cf" }, "downloads": -1, "filename": "img2pdf-0.3.3.tar.gz", "has_sig": true, "md5_digest": "211c7bfacebbccccffe47f5b732921a5", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 80523, "upload_time": "2019-01-07T09:45:05", "url": "https://files.pythonhosted.org/packages/e0/c6/7cd14232a1b10bf884c12daf3626afb76c4f60b52ae0eb23ce1519542ae4/img2pdf-0.3.3.tar.gz" } ] }