{"id":118,"date":"2021-02-12T10:41:17","date_gmt":"2021-02-12T09:41:17","guid":{"rendered":"http:\/\/www.hansbaas.com\/?p=118"},"modified":"2021-08-14T15:35:49","modified_gmt":"2021-08-14T15:35:49","slug":"resizing-images-in-bulk-in-linux","status":"publish","type":"post","link":"https:\/\/www.hansbaas.com\/?p=118","title":{"rendered":"Resizing images in bulk in linux"},"content":{"rendered":"\n<p>Who hasn&#8217;t found himself in a situation where you have to make changes to multiple images and you get fed up with doing the job one image at a time? Well today I had to combine 13 images into a single pdf and it came out way to large to be useful.<\/p>\n\n\n\n<!--more-->\n\n\n\n<p>First of all, you need to have installed imagemagick on your machine. To combine multiple files into one, you type<br><code>convert *.jpg output.pdf<\/code><br>(this works for other filetypes too by the way)<\/p>\n\n\n\n<p>Now instead of  reducing the size and resolution (to keep the same paper size) of the images by 50% one by one, we add instructions to imagemagick. Let&#8217;s say our original images where from scans in 300dpi resolution and 2480 by 3508 pixels. We would run<br><code>convert -size 1240x1754 -density 150 *.jpg output.pdf<\/code><\/p>\n\n\n\n<p>Now, instead of having a 20MB pdf, I got around 6MB, which I can send by e-mail without hassles for the receiving party. In preparing the jpg originals it would also have been useful to set the quality around 80.<\/p>\n\n\n\n<p>If you get a pdf that doesn&#8217;t have normal page size, try and print it to file, creating a new pdf with selected paper size.<\/p>\n\n\n\n<p>If you want to reduce an existing pdf you can get 300dpi, 150dpi or 72dpi with the following ghostscript command:<br><code>gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=\/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=path\/output.pdf path\/input.pdf<\/code><br>where -dPDFSETTINGS=\/ can be followed by preprint (300dpi), ebook (150dpi) or screen (72dpi).<\/p>\n\n\n\n<p><a href=\"https:\/\/imagemagick.org\/script\/index.php\">Imagemagick.org<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Who hasn&#8217;t found himself in a situation where you have to make changes to multiple images and you get fed up with doing the job one image at a time? Well today I had to combine 13 images into a single pdf and it came out way to large to be useful.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[11,22,26,27],"class_list":["post-118","post","type-post","status-publish","format-standard","hentry","category-nerd","tag-bulk","tag-images","tag-pdf","tag-resizing"],"_links":{"self":[{"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=\/wp\/v2\/posts\/118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=118"}],"version-history":[{"count":2,"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions"}],"predecessor-version":[{"id":193,"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=\/wp\/v2\/posts\/118\/revisions\/193"}],"wp:attachment":[{"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=118"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=118"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.hansbaas.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}