{"id":4023,"date":"2024-05-09T19:16:12","date_gmt":"2024-05-09T10:16:12","guid":{"rendered":"https:\/\/matoken.org\/blog\/?p=4023"},"modified":"2024-05-09T19:16:14","modified_gmt":"2024-05-09T10:16:14","slug":"images-to-pdf","status":"publish","type":"post","link":"https:\/\/matoken.org\/blog\/2024\/05\/09\/images-to-pdf\/","title":{"rendered":"jpeg \u753b\u50cf\u7fa4\u3092 PDF \u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db(ImageMagick, imgpdf)"},"content":{"rendered":"<div class=\"paragraph\">\n<p>\u5148\u65e5\u56fd\u7acb\u56fd\u4f1a\u56f3\u66f8\u9928\u30c7\u30b8\u30bf\u30eb\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8535\u66f8\u306e\u753b\u50cf\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u4f59\u767d\u3092\u30ab\u30c3\u30c8\u3057\u3066\u8aad\u307f\u3084\u3059\u304f\u3057\u307e\u3057\u305f\uff0ejpeg \u3092 zip \u30a2\u30fc\u30ab\u30a4\u30d6\u306b\u307e\u3068\u3081\u305f\u306e\u3067\u3059\u304c\uff0cPDF \u30d5\u30a1\u30a4\u30eb\u306e\u307b\u3046\u304c\u90fd\u5408\u304c\u3044\u3044\u3053\u3068\u3082\uff0e\u3068\u3044\u3046\u3053\u3068\u3067 jpeg \u30d5\u30a1\u30a4\u30eb\u7fa4\u3092 PDF \u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3057\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li><a href=\"https:\/\/matoken.org\/blog\/2024\/05\/02\/remove-image-margins\/\">\u56fd\u7acb\u56fd\u4f1a\u56f3\u66f8\u9928\u30c7\u30b8\u30bf\u30eb\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8535\u66f8\u306e\u753b\u50cf\u306e\u4f59\u767d\u3092\u524a\u9664\u3057\u3066\u8aad\u307f\u3084\u3059\u304f\u3059\u308b \u2013 matoken\u2019s meme<\/a><\/li>\n<\/ul>\n<\/div>\n<p><!--more--><\/p>\n<div class=\"paragraph\">\n<p>ImageMagick \u306e convert \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u3068\u30e1\u30e2\u30ea\u4e0d\u8db3\u3067\u5931\u6557\uff0c\u30dd\u30ea\u30b7\u30fc\u30d5\u30a1\u30a4\u30eb\u306e <code>\/etc\/ImageMagick-6\/policy.xml<\/code> \u3067\u30e1\u30e2\u30ea\u30ea\u30bd\u30fc\u30b9\u3092 1GB \u304b\u3089 4GB \u306b\u8a2d\u5b9a\u3057\u3066\u3082\u5931\u6557\u3057\u30668GB \u306b\u8a2d\u5b9a\u3057\u3066\u3084\u3063\u3068\u51e6\u7406\u304c\u51fa\u6765\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ convert  2530201\/* \u5b87\u5b99\u8239\u30d3\u30fc\u30b0\u30eb\u53f7\u306e\u5192\u967a.pdf <b class=\"conum\">(1)<\/b>\n  :\nconvert-im6.q16: cache resources exhausted `2530201\/2530201-107.jpg' @ error\/cache.c\/OpenPixelCache\/4119.\nconvert-im6.q16: TooManyExceptions (exception processing is suspended) @ warning\/exception.c\/ThrowException\/1054.\nconvert-im6.q16: cache resources exhausted `2530201\/2530201-108.jpg' @ error\/cache.c\/OpenPixelCache\/4119.\n$ identify -list resource <b class=\"conum\">(2)<\/b>\nResource limits:\n  Width: 32KP\n  Height: 32KP\n  List length: unlimited\n  Area: 256MP\n  Memory: 1GiB\n  Map: 2GiB\n  Disk: 2GiB\n  File: 768\n  Thread: 4\n  Throttle: 0\n  Time: unlimited\n$ identify -limit memory 4096MiB -list resource | grep ^\\ \\ Memory: <b class=\"conum\">(3)<\/b>\n  Memory: 1GiB\n$ identify -limit memory 512MiB -list resource | grep ^\\ \\ Memory: <b class=\"conum\">(4)<\/b>\n  Memory: 512MiB\n$ sudo git -C \/etc diff \/etc\/ImageMagick-6\/policy.xml <b class=\"conum\">(5)<\/b>\ndiff --git a\/ImageMagick-6\/policy.xml b\/ImageMagick-6\/policy.xml\nindex 4b878ce..aa54cbe 100644\n--- a\/ImageMagick-6\/policy.xml\n+++ b\/ImageMagick-6\/policy.xml\n@@ -95,7 +95,7 @@\n   &lt;!-- Set maximum amount of memory in bytes to allocate for the pixel cache\n        from the heap. When this limit is exceeded, the image pixels are cached\n        to memory-mapped disk. --&gt;\n-  &lt;policy domain=\"resource\" name=\"memory\" value=\"1024MiB\"\/&gt;\n+  &lt;policy domain=\"resource\" name=\"memory\" value=\"4096MiB\"\/&gt;\n   &lt;!-- Set maximum amount of memory map in bytes to allocate for the pixel\n        cache. When this limit is exceeded, the image pixels are cached to\n        disk. --&gt;\n$ identify -list resource | grep ^\\ \\ Memory: <b class=\"conum\">(6)<\/b>\n  Memory: 4GiB<\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>ImageMagick \u306e convert \u30b3\u30de\u30f3\u30c9\u3067 PDF \u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3057\u305f\u304c\u9014\u4e2d\u3067\u5931\u6557<\/li>\n<li>ImageMagick \u306e \u30ea\u30bd\u30fc\u30b9\u3092\u78ba\u8a8d<\/li>\n<li>limit memory \u3067\u5927\u304d\u304f\u306f\u51fa\u6765\u306a\u3044<\/li>\n<li>limit memory \u3067\u5c0f\u3055\u304f\u306f\u51fa\u6765\u308b<\/li>\n<li>ImageMagick \u306e\u30dd\u30ea\u30b7\u30fc\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u3066\u30e1\u30e2\u30ea\u5229\u7528\u53ef\u80fd\u91cf\u3092\u5897\u3084\u3057\u305f<\/li>\n<li>\u30e1\u30e2\u30ea\u5229\u7528\u53ef\u80fd\u91cf\u304c\u5897\u3048\u305f\u306e\u3092\u78ba\u8a8d<\/li>\n<\/ol>\n<\/div>\n<div class=\"paragraph\">\n<p>\u3044\u3061\u304a\u3046\u3053\u308c\u3067\u8fd4\u9084\u3067\u3057\u307e\u3057\u305f\u304c\uff0c\u3053\u306e\u30e1\u30e2\u30ea\u5229\u7528\u91cf\u3068\u5909\u63db\u6642\u9593\u306f\u5927\u304d\u3059\u304e\u308b\u306e\u3067\u4ed6\u306e\u65b9\u6cd5\u3092\u63a2\u3057\u307e\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>img2pdf \u3068\u3044\u3046\u30b3\u30de\u30f3\u30c9\u3092\u898b\u3064\u3051\u307e\u3057\u305f\uff0e\u3053\u306e\u30b3\u30de\u30f3\u30c9\u306f\u53ef\u80fd\u306a\u3089\u30ed\u30b9\u30ec\u30b9\u3067\u753b\u50cf\u3092 PDF \u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3057\u3066\u304f\u308c\u308b\u306e\u3067\u9ad8\u901f(\u304b\u3064\u7701\u30ea\u30bd\u30fc\u30b9\u306a\u306f\u305a)\u3067\u51e6\u7406\u3067\u304d\u305d\u3046\u3067\u3059\uff0e<\/p>\n<\/div>\n<div class=\"ulist\">\n<ul>\n<li><a href=\"https:\/\/gitlab.mister-muffin.de\/josch\/img2pdf\">josch\/img2pdf &#8211; img2pdf &#8211; Muffin Gitea<\/a><\/li>\n<\/ul>\n<\/div>\n<div class=\"paragraph\">\n<p>\u5c0e\u5165\u306f\u30c7\u30a3\u30b9\u30c8\u30ea\u30d3\u30e5\u30fc\u30b7\u30e7\u30f3\u30d1\u30c3\u30b1\u30fc\u30b8\u304b\u3089\uff0e\u5b9f\u884c\u901f\u5ea6\u3082\u3068\u3066\u3082\u65e9\u304b\u3063\u305f\u3067\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ sudo apt install img2pdf <b class=\"conum\">(1)<\/b>\n$ img2pdf -o \u5b87\u5b99\u8239\u30d3\u30fc\u30b0\u30eb\u53f7\u306e\u5192\u967a-img2pdf.pdf 2530201\/* <b class=\"conum\">(2)<\/b>\nfind 2530201 -type f -print0 | sort -Vz | xargs -0 img2pdf -o \u5b87\u5b99\u8239\u30d3\u30fc\u30b0\u30eb\u53f7\u306e\u5192\u967a.pdf <b class=\"conum\">(3)<\/b><\/pre>\n<\/div>\n<\/div>\n<div class=\"colist arabic\">\n<ol>\n<li>img2pdf \u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u5c0e\u5165<\/li>\n<li>PDF \u306b\u5909\u63db<\/li>\n<li>\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u540d\u3067\u4e26\u3079\u66ff\u3048\u3066\u6a19\u6e96\u5165\u529b\u304b\u3089\u753b\u50cf\u30d5\u30a1\u30a4\u30eb\u30ea\u30b9\u30c8\u3092\u6e21\u3057\uff0cPDF \u30d5\u30a1\u30a4\u30eb\u306b<\/li>\n<\/ol>\n<\/div>\n<div class=\"paragraph\">\n<p>\u5909\u63db\u6642\u9593\u306e\u6bd4\u8f03\u3067\u3059\uff0econvert \u304c\u7570\u69d8\u306b\u9045\u3044\u3067\u3059\u304c\uff0c\u3053\u308c\u306f\u30b9\u30ef\u30c3\u30d7\u3092\u4f7f\u3063\u3066\u3057\u307e\u3063\u3066\u3044\u308b\u306e\u3082\u5927\u304d\u3044\u3068\u601d\u308f\u308c\uff0c\u30e1\u30e2\u30ea\u306e\u5927\u304d\u3044\u30de\u30b7\u30f3\u3060\u3068\u3082\u3063\u3068\u65e9\u304f\u306a\u308b\u3068\u601d\u3044\u307e\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"content\">\n<pre>$ time convert 2530201\/* \u5b87\u5b99\u8239\u30d3\u30fc\u30b0\u30eb\u53f7\u306e\u5192\u967a.pdf\n\nreal    5m18.636s\nuser    0m47.748s\nsys     0m31.136s\n$ time img2pdf -o \u5b87\u5b99\u8239\u30d3\u30fc\u30b0\u30eb\u53f7\u306e\u5192\u967a-img2pdf.pdf 2530201\/*\n\nreal    0m1.279s\nuser    0m0.556s\nsys     0m0.180s<\/pre>\n<\/div>\n<\/div>\n<div class=\"paragraph\">\n<p>\u5b9f\u969b\u306e\u753b\u50cf\u3082\u7279\u306b\u554f\u984c\u306a\u3055\u305d\u3046\u3060\u3057\uff0c\u30d5\u30a1\u30a4\u30eb\u30b5\u30a4\u30ba\u3082\u307b\u3068\u3093\u3069\u5909\u308f\u308a\u307e\u305b\u3093\u3067\u3057\u305f\uff0e<\/p>\n<\/div>\n<div class=\"paragraph\">\n<p>\u5358\u7d14\u306b\u753b\u50cf\u3092 PDF \u30d5\u30a1\u30a4\u30eb\u306b\u5909\u63db\u3059\u308b\u6642\u306f img2pdf \u30b3\u30de\u30f3\u30c9\u3092\u4f7f\u3046\u306e\u304c\u826f\u3055\u305d\u3046\u3067\u3059\uff0e<\/p>\n<\/div>\n<div class=\"listingblock\">\n<div class=\"title\">\u74b0\u5883<\/div>\n<div class=\"content\">\n<pre>$ dpkg-query -W imagemagick img2pdf\nimagemagick     8:6.9.12.98+dfsg1-5.2\nimg2pdf 0.5.1-1\n$ lsb_release -a\nNo LSB modules are available.\nDistributor ID: Debian\nDescription:    Debian GNU\/Linux trixie\/sid\nRelease:        n\/a\nCodename:       trixie\n$ arch\nx86_64<\/pre>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u5148\u65e5\u56fd\u7acb\u56fd\u4f1a\u56f3\u66f8\u9928\u30c7\u30b8\u30bf\u30eb\u30b3\u30ec\u30af\u30b7\u30e7\u30f3\u306e\u8535\u66f8\u306e\u753b\u50cf\u3092\u30c0\u30a6\u30f3\u30ed\u30fc\u30c9\u3057\u3066\u4f59\u767d\u3092\u30ab\u30c3\u30c8\u3057\u3066\u8aad\u307f\u3084\u3059\u304f\u3057\u307e\u3057\u305f\uff0ejpeg \u3092 zip \u30a2\u30fc\u30ab\u30a4\u30d6\u306b\u307e\u3068\u3081\u305f\u306e\u3067\u3059\u304c\uff0cPDF \u30d5\u30a1\u30a4\u30eb\u306e\u307b\u3046\u304c\u90fd\u5408\u304c\u3044\u3044\u3053\u3068\u3082\uff0e\u3068\u3044\u3046\u3053\u3068\u3067 jpeg [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"webmentions_disabled_pings":false,"webmentions_disabled":false,"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"federated","footnotes":""},"categories":[7,6,199],"tags":[362,817,442],"class_list":["post-4023","post","type-post","status-publish","format-standard","hentry","category-debian-linux","category-linux","category-sid","tag-imagemagick","tag-img2jpg","tag-pdf"],"_links":{"self":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/4023","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/comments?post=4023"}],"version-history":[{"count":2,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/4023\/revisions"}],"predecessor-version":[{"id":4025,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/posts\/4023\/revisions\/4025"}],"wp:attachment":[{"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/media?parent=4023"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/categories?post=4023"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/matoken.org\/blog\/wp-json\/wp\/v2\/tags?post=4023"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}