From 21a37f359c1a5960693bc216ddf976790cc19add Mon Sep 17 00:00:00 2001 From: Marcin Deranek Date: Thu, 21 Dec 2023 01:48:05 +0100 Subject: media-gfx/img2pdf initial ebuild --- media-gfx/img2pdf/Manifest | 4 ++ media-gfx/img2pdf/files/remove-exact-cmyk8.patch | 85 ++++++++++++++++++++++++ media-gfx/img2pdf/img2pdf-0.5.1.ebuild | 54 +++++++++++++++ media-gfx/img2pdf/metadata.xml | 24 +++++++ 4 files changed, 167 insertions(+) create mode 100644 media-gfx/img2pdf/Manifest create mode 100644 media-gfx/img2pdf/files/remove-exact-cmyk8.patch create mode 100644 media-gfx/img2pdf/img2pdf-0.5.1.ebuild create mode 100644 media-gfx/img2pdf/metadata.xml (limited to 'media-gfx') diff --git a/media-gfx/img2pdf/Manifest b/media-gfx/img2pdf/Manifest new file mode 100644 index 0000000..c2800c2 --- /dev/null +++ b/media-gfx/img2pdf/Manifest @@ -0,0 +1,4 @@ +AUX remove-exact-cmyk8.patch 3347 BLAKE2B 61700badf3a9dac027d553554ce991c341a5cb869dc29033128c1557074e6b7a2bd3ecf7b9a0cd7d077ba038dee0f9e3a561f10211cbdb193b382e0ae449d7c2 SHA512 4a68d91eda35c5fe4933e84bc368e14d655a38312bea7fe5429685da52d45e18dbc21566db126b3830d35b4389fa7d45067a86aa8cbc3312e83b367ff9793077 +DIST img2pdf-0.5.1.tar.gz 104241 BLAKE2B 1ea89107654c91cea8b5f074c05c7376452dd2ebd40dafaadedb39ac3ee383c3c02c1375b130da73339e1f87eb1a6ffbe0553cdedf6ec997bc0731d1d100327f SHA512 e17a920929f6ab08f501b205c38f9cf2fd5a6bd8d41ac4819a5d7463a3cfbeb5376cd5bbee36ab303248610f1d5c8a71a38ff85b14be564e2f39c6eb537ffcaf +EBUILD img2pdf-0.5.1.ebuild 1194 BLAKE2B 3b9530b6acdd98d0b18ab4f030d15fb6e9918804e14dcd09795ed070177bd1cf7d3f0c8b70e80f310ae23355c221d1a9b898d58858fda6adb8f4fb91e07cb3db SHA512 89909e9df8de3968ebcdb325f0d05c812fd5e22fad8b04e3cb6d2b1d423c040cb34f2be271e0ad2f7ea90e4c0353e2fbd818646798277fa41a06ece3b762b93b +MISC metadata.xml 1019 BLAKE2B 5c6db1304339112586563d41c64ee3b89f3e714d6587d6a4a0bac2159fe57c7ebeaf9e2bb14f225c2a05dce11147c9a02b63961b47588bd5bb6dc9f2ebb265d0 SHA512 1b8b8c137f24b682c97944fa38997c86aaeba8cbb2c86fc20277c992f23d07a7382315287734ab37cf9bec3be0593181dd875ca8453351e37ac27a6d1ec5ae6f diff --git a/media-gfx/img2pdf/files/remove-exact-cmyk8.patch b/media-gfx/img2pdf/files/remove-exact-cmyk8.patch new file mode 100644 index 0000000..a0f00de --- /dev/null +++ b/media-gfx/img2pdf/files/remove-exact-cmyk8.patch @@ -0,0 +1,85 @@ +Subject: remove HAVE_EXACT_CMYK8 +From: Johannes Schauer Marin Rodrigues + +--- a/src/img2pdf_test.py ++++ b/src/img2pdf_test.py +@@ -85,7 +85,6 @@ for prog in ["convert", "compare", "iden + globals()[prog.upper()] = ["magick", prog] + + HAVE_IMAGEMAGICK_MODERN = True +-HAVE_EXACT_CMYK8 = True + try: + ver = subprocess.check_output(CONVERT + ["-version"], stderr=subprocess.STDOUT) + m = re.fullmatch( +@@ -93,18 +92,13 @@ try: + ) + if m is None: + HAVE_IMAGEMAGICK_MODERN = False +- HAVE_EXACT_CMYK8 = False + else: + if parse_version(m.group(1)) < parse_version("6.9.10-12"): + HAVE_IMAGEMAGICK_MODERN = False +- if parse_version(m.group(1)) < parse_version("7.1.0-48"): +- HAVE_EXACT_CMYK8 = False + except FileNotFoundError: + HAVE_IMAGEMAGICK_MODERN = False +- HAVE_EXACT_CMYK8 = False + except subprocess.CalledProcessError: + HAVE_IMAGEMAGICK_MODERN = False +- HAVE_EXACT_CMYK8 = False + + if not HAVE_IMAGEMAGICK_MODERN: + warnings.warn("imagemagick >= 6.9.10-12 not available, skipping certain checks...") +@@ -351,9 +345,7 @@ def write_png(data, path, bitdepth, colo + + def compare(im1, im2, exact, icc, cmyk): + if exact: +- if cmyk and not HAVE_EXACT_CMYK8: +- raise Exception("cmyk cannot be exact before ImageMagick 7.1.0-48") +- elif icc: ++ if icc: + raise Exception("icc cannot be exact") + else: + subprocess.check_call( +@@ -5562,11 +5554,9 @@ def test_jpg_rot(tmp_path_factory, jpg_r + ) + def test_jpg_cmyk(tmp_path_factory, jpg_cmyk_img, jpg_cmyk_pdf): + tmpdir = tmp_path_factory.mktemp("jpg_cmyk") +- compare_ghostscript( +- tmpdir, jpg_cmyk_img, jpg_cmyk_pdf, gsdevice="tiff32nc", exact=HAVE_EXACT_CMYK8 +- ) ++ compare_ghostscript(tmpdir, jpg_cmyk_img, jpg_cmyk_pdf, gsdevice="tiff32nc") + # not testing with poppler as it cannot write CMYK images +- compare_mupdf(tmpdir, jpg_cmyk_img, jpg_cmyk_pdf, exact=HAVE_EXACT_CMYK8, cmyk=True) ++ compare_mupdf(tmpdir, jpg_cmyk_img, jpg_cmyk_pdf, cmyk=True) + compare_pdfimages_cmyk(tmpdir, jpg_cmyk_img, jpg_cmyk_pdf) + + +@@ -5957,12 +5947,9 @@ def test_tiff_cmyk8(tmp_path_factory, ti + tiff_cmyk8_img, + tiff_cmyk8_pdf, + gsdevice="tiff32nc", +- exact=HAVE_EXACT_CMYK8, + ) + # not testing with poppler as it cannot write CMYK images +- compare_mupdf( +- tmpdir, tiff_cmyk8_img, tiff_cmyk8_pdf, exact=HAVE_EXACT_CMYK8, cmyk=True +- ) ++ compare_mupdf(tmpdir, tiff_cmyk8_img, tiff_cmyk8_pdf, cmyk=True) + compare_pdfimages_tiff(tmpdir, tiff_cmyk8_img, tiff_cmyk8_pdf) + + +@@ -6403,11 +6390,9 @@ def test_tiff_ccitt_nometa2( + ) + def test_miff_cmyk8(tmp_path_factory, miff_cmyk8_img, tiff_cmyk8_img, miff_cmyk8_pdf): + tmpdir = tmp_path_factory.mktemp("miff_cmyk8") +- compare_ghostscript( +- tmpdir, tiff_cmyk8_img, miff_cmyk8_pdf, gsdevice="tiff32nc", exact=False +- ) ++ compare_ghostscript(tmpdir, tiff_cmyk8_img, miff_cmyk8_pdf, gsdevice="tiff32nc") + # not testing with poppler as it cannot write CMYK images +- compare_mupdf(tmpdir, tiff_cmyk8_img, miff_cmyk8_pdf, exact=False, cmyk=True) ++ compare_mupdf(tmpdir, tiff_cmyk8_img, miff_cmyk8_pdf, cmyk=True) + compare_pdfimages_tiff(tmpdir, tiff_cmyk8_img, miff_cmyk8_pdf) + + diff --git a/media-gfx/img2pdf/img2pdf-0.5.1.ebuild b/media-gfx/img2pdf/img2pdf-0.5.1.ebuild new file mode 100644 index 0000000..3158ece --- /dev/null +++ b/media-gfx/img2pdf/img2pdf-0.5.1.ebuild @@ -0,0 +1,54 @@ +# Copyright 1999-2023 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +DISTUTILS_USE_PEP517=setuptools +PYTHON_COMPAT=( python3_{9..11} ) + +inherit distutils-r1 pypi + +DESCRIPTION="Losslessly convert raster images to PDF" +HOMEPAGE="https://gitlab.mister-muffin.de/josch/img2pdf" + +LICENSE="LGPL-3+" +SLOT="0" +KEYWORDS="amd64 ppc64 x86" +IUSE="gui" + +PATCHES=( + "${FILESDIR}/remove-exact-cmyk8.patch" +) + +BDEPEND=" + test? ( + app-text/ghostscript-gpl + app-text/mupdf + app-text/poppler[cairo,png,tiff] + dev-python/numpy[${PYTHON_USEDEP}] + dev-python/pdfrw[${PYTHON_USEDEP}] + dev-python/pillow[tiff,${PYTHON_USEDEP}] + dev-python/scipy[${PYTHON_USEDEP}] + media-gfx/imagemagick[jpeg,jpeg2k,lcms,png,-q8,-q32,tiff] + media-libs/exiftool + media-libs/netpbm[jpeg] + sys-libs/libfaketime + ) +" +RDEPEND=" + dev-python/pikepdf[${PYTHON_USEDEP}] + dev-python/pillow[${PYTHON_USEDEP}] + media-libs/icc-profiles-openicc + gui? ( $(python_gen_impl_dep tk) ) +" + +distutils_enable_tests pytest + +src_prepare() { + distutils-r1_python_prepare_all + + # Remove gui executable if there's no demand/support for it. + if ! use gui; then + sed -i '/gui_scripts/d' setup.py || die + fi +} diff --git a/media-gfx/img2pdf/metadata.xml b/media-gfx/img2pdf/metadata.xml new file mode 100644 index 0000000..c62baa9 --- /dev/null +++ b/media-gfx/img2pdf/metadata.xml @@ -0,0 +1,24 @@ + + + + + marcin.deranek@slonko.net + Marcin Deranek + + + Losslessly convert raster images to PDF. The file size will not + unnecessarily 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 in + the PDF becoming unnecessarily large in terms of its file size. + + + + josch@mister-muffin.de + Johannes Schauer + + img2pdf + https://gitlab.mister-muffin.de/josch/img2pdf/issues + + -- cgit v1.2.3