{"id":118472,"date":"2020-11-23T18:00:41","date_gmt":"2020-11-23T15:00:41","guid":{"rendered":"https:\/\/en.buradabiliyorum.com\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/"},"modified":"2020-11-23T18:00:41","modified_gmt":"2020-11-23T15:00:41","slug":"convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it","status":"publish","type":"post","link":"https:\/\/buradabiliyorum.com\/en\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/","title":{"rendered":"#Convert PDF to Images From the Linux Command Line \u2013 CloudSavvy IT"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<label for=\"ez-toc-cssicon-toggle-item-6a2d5d1b2ccd5\" class=\"ez-toc-cssicon-toggle-label\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #dd3333;color:#dd3333\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #dd3333;color:#dd3333\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/label><input type=\"checkbox\"  id=\"ez-toc-cssicon-toggle-item-6a2d5d1b2ccd5\" checked aria-label=\"Toggle\" \/><nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/buradabiliyorum.com\/en\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/#What_Is_poppler-utils\" >What Is poppler-utils ?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/buradabiliyorum.com\/en\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/#Installing_poppler-utils\" >Installing\u00a0poppler-utils<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/buradabiliyorum.com\/en\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/#Converting_PDF_to_images\" >Converting PDF to images<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/buradabiliyorum.com\/en\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/#Batch_Processing_of_PDF_Files_to_Images\" >Batch Processing of PDF Files to Images<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/buradabiliyorum.com\/en\/convert-pdf-to-images-from-the-linux-command-line-cloudsavvy-it\/#Wrapping_up\" >Wrapping up<\/a><\/li><\/ul><\/nav><\/div>\n<p><strong>&#8220;#Convert PDF to Images From the Linux Command Line \u2013 CloudSavvy IT&#8221;<\/strong><\/p>\n<div id=\"article-content-area\">\n<figure id=\"attachment_8144\" style=\"width: 700px\" class=\"wp-caption alignnone\"><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-8144 size-full\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/f39cdb89381c3f06041192a71ec5ace4\/p\/uploads\/2020\/11\/ffa1bfc5.png\" alt=\"\" width=\"700\" height=\"300\" data-crediturl=\"https:\/\/www.shutterstock.com\/image-vector\/download-pdf-button-on-laptop-screen-1252525834\" data-credittext=\"Shutterstock\/Tetiana Yurchenko\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><figcaption class=\"wp-caption-text\"><span class=\"imagecredit\"><a rel=\"nofollow noopener noreferrer\" target=\"_blank\" href=\"https:\/\/www.shutterstock.com\/image-vector\/download-pdf-button-on-laptop-screen-1252525834\">Shutterstock\/Tetiana Yurchenko<\/a><\/span><\/figcaption><\/figure>\n<p>Converting a PDF file to an image can be done easily at the Linux command line using a single command. Discover how to do install the utility, how to use it, and how to automate your setup.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"What_Is_poppler-utils\"><\/span>What Is <i>poppler-utils<\/i> ?<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>As alluded to in the introduction for this article, we need to install a small utility set named <i>poppler-utils<\/i> to help us convert PDF files to images.<\/p>\n<p>The poppler-utils utility set allows us to convert images to PDF, and PDF to images.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Installing_poppler-utils\"><\/span>Installing\u00a0<i>poppler-utils<\/i><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8132\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/0807a1dc66d948d439221715244bc2cf\/p\/uploads\/2020\/11\/bf5e1b99.png\" alt=\"installing poppler-utils\" width=\"916\" height=\"324\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>To install <i>poppler-utils<\/i> on your Debian\/Apt based Linux distribution (Like Ubuntu and Mint), do:<\/p>\n<p><code>sudo apt install poppler-utils<\/code><\/p>\n<p>To install <i>poppler-utils<\/i> on your RedHat\/Yum based Linux distribution (Like RedHat and Fedora), do:<\/p>\n<p><code>sudo yum install poppler-utils<\/code><\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Converting_PDF_to_images\"><\/span>Converting PDF to images<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The command required is simple and straightforward:<\/p>\n<pre>pdftoppm -png test.pdf test&#13;\n<\/pre>\n<p>With the <code>pdftoppm<\/code> command we can convert PDF to images. We specify that we want a PNG file for the output format (by using <code>-png<\/code>) and that our input file is <code>test.pdf<\/code>.<\/p>\n<p>The output file we specify as <code>test<\/code>. <code>pdftoppm<\/code> will automatically add a page number suffix (like <i>-1<\/i>) and an extension (based on the earlier <code>-png<\/code> option passed).<\/p>\n<p>The output file name will thus be <code>test-1.png<\/code>, as we can verify next:<\/p>\n<pre>ls test-1.png&#13;\neog test-1.png &#13;\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8134\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/553012c04e71efdda06cb0c6e523f9a0\/p\/uploads\/2020\/11\/5617c8a8.png\" alt=\"pdftoppm converting a pdf file to an image at the Linux command line\" width=\"287\" height=\"90\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>Any subsequent pages would be <i>test-2.png<\/i> etc. The <code>eog<\/code> command (if <i>eog<\/i> is installed) will open the file for you so you can review the output, though you can use any other image handling program you like.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Batch_Processing_of_PDF_Files_to_Images\"><\/span>Batch Processing of PDF Files to Images<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>We can make a one-liner command to do batch processing of all PDF files with a given name to images. We could then simply add this line to a small <a href=\"https:\/\/buradabiliyorum.com\/en\/category\/download-scripts-themes-apps\/\" data-internallinksmanager029f6b8e52c=\"9\" title=\"Download Scripts &amp; Themes &amp; Apps\" target=\"_blank\" rel=\"noopener\">script<\/a> <i>.sh<\/i> file and automate it further, or we can just use it at the command line whenever we need to convert a large amount of PDF files to images.<\/p>\n<pre>ls --color=never test*.pdf | sed 's|.pdf||' | xargs -I{} pdftoppm {}.pdf -png {}<\/pre>\n<p>In this command, we first obtain a directory listing for all PDF files which have a name that starts with <i>test<\/i> and ends with <i>.pdf<\/i>, using the <code>ls --color=never test*.pdf<\/code>.<\/p>\n<p>The <code>--color=never<\/code> is important, as shell color coding symbols (if active, as they are by default) may sometimes confuse <i>xargs<\/i>.<\/p>\n<p>Next we use a simple <code>sed<\/code> substitute command to replace a literal dot followed by pdf to nothing. In other words, we remove the <i>.pdf<\/i> file extension.<\/p>\n<p>This gives us the benefit of adding it back later only where needed, i.e. when specifying the input file for <code>pdftoppm<\/code>, but not when specifying the output file for the same <code>pdftoppm<\/code> command, much alike to our earlier example above.<\/p>\n<p>Finally, we use <code>xargs<\/code> to sent each pdf filename (minus the <i>.pdf<\/i>) to <code>pdftoppm<\/code> one by one. We use the <code>-I<\/code> option to <code>xargs<\/code> which allows us to specify any input received (i.e. the shortened pdf filenames) by simply using <code>{}<\/code> in the command that follows.<\/p>\n<p>As you can see, our <code>pdftoppm<\/code> command now looks much alike to the first example, with each individual pdf file name as input (re-suffixed with <i>.pdf<\/i>), and as output the pdf filename without <i>.pdf<\/i>.<\/p>\n<p>Let\u2019s execute it:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-8135\" src=\"https:\/\/www.cloudsavvyit.com\/thumbcache\/0\/0\/6b2c9148115e6fdc74391c3345455de7\/p\/uploads\/2020\/11\/3d7c3fd3.png\" alt=\"Automatin of pdftoppm converting multiple pdf files to images\" width=\"637\" height=\"108\" onload=\"pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\" onerror=\"this.onerror=null;pagespeed.lazyLoadImages.loadIfVisibleAndMaybeBeacon(this);\"\/><\/p>\n<p>This worked fine: the three PDF files, all with one page each, were converted to three individual <i>.png<\/i> files (one image per page and in this case per PDF as each PDF had only one page), all aptly named and suffixed correctly.<\/p>\n<p>As an alternative to the <code>-png<\/code> option, one can also use <code>-jpeg<\/code> to generate JPEG files instead. Use <code>pdftoppm --help<\/code> or <code>man pdftoppm<\/code> to see a full list of options.<\/p>\n<h2 role=\"heading\" aria-level=\"2\"><span class=\"ez-toc-section\" id=\"Wrapping_up\"><\/span>Wrapping up<span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>In this article we saw how easy and straightforward it can be to convert PDF files to image files, and that directly from the Linux command line! We also look at a straightforward way to automate this process. <strong>Enjoy!<\/strong>\n<\/div>\n<blockquote><p><strong><span style=\"color: #ff6600;\">If you liked the article, do not forget to share it with your friends. Follow us on\u00a0<span style=\"color: #ff0000;\"><a style=\"color: #ff0000;\" href=\"https:\/\/news.google.com\/publications\/CAAqBwgKMLG0nwswvr63Aw\" target=\"_blank\" rel=\"nofollow noopener noreferrer\">Google News<\/a><\/span>\u00a0too, click on the star and choose us from your favorites.<\/span><\/strong><\/p><\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\">For forums sites go to <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/forum.buradabiliyorum.com\/\" target=\"_blank\" rel=\"noopener noreferrer\">Forum.BuradaBiliyorum.Com<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<blockquote>\n<p style=\"text-align: center;\"><strong>If you want to read more like this article, you can visit our <span style=\"color: #ff9900;\"><a style=\"color: #ff9900;\" href=\"https:\/\/en.buradabiliyorum.com\/technology\/\" target=\"_blank\" rel=\"noopener noreferrer\">Technology category.<\/a><\/span><\/strong><\/p>\n<\/blockquote>\n<p><span style=\"color: black;\"><a style=\"color: #ff9900;\" href=\"https:\/\/www.cloudsavvyit.com\/8131\/convert-pdf-to-images-from-the-linux-command-line\/\" target=\"_blank\" rel=\"noopener noreferrer\">Source<\/a><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>&#8220;#Convert PDF to Images From the Linux Command Line \u2013 CloudSavvy IT&#8221; Shutterstock\/Tetiana Yurchenko Converting a PDF file to an image can be done easily at the Linux command line using a single command. Discover how to do install the utility, how to use it, and how to automate your setup. What Is poppler-utils ?&#8230;<\/p>\n","protected":false},"author":1,"featured_media":118473,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"fifu_image_url":"https:\/\/www.cloudsavvyit.com\/p\/uploads\/2020\/11\/ffa1bfc5.png","fifu_image_alt":"","footnotes":""},"categories":[18],"tags":[],"class_list":["post-118472","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-technology"],"_links":{"self":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/118472","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/comments?post=118472"}],"version-history":[{"count":0,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/posts\/118472\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media\/118473"}],"wp:attachment":[{"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/media?parent=118472"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/categories?post=118472"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buradabiliyorum.com\/en\/wp-json\/wp\/v2\/tags?post=118472"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}