3

I have several pages imported from scanner in PNG format. I use image editor to clean some noise, downscale to 100PDI, convert image palette to grayscale, etc. Finally I've got a bunch of PNG images of small size, looking good at computer screen still.

Then I need to save these PNG pages to a single PDF file for distribution. Earlier I was able to achieve this using Preview.app. However in macOS X High Sierra 10.13 this approach does not work any longer because Preview.app is trying to downscale PNG images by 30% to fit page size. After this transform the image is not sharp enough any longer.

In earlier versions of macOS X Preview.app generated PDF file without transforming the images.

Is there a way to make a PDF file from a set of PNG images using these images as-is (without any transformation)?

  • "downscale to 100dpi" - changing dpi does not affect the image size at all, merely how a page-layout app will treat it when placed. Could you clarify exactly what your method is? – Tetsujin Jan 7 '18 at 10:33
  • @Tetsujin, when I change DPI from 300 to 100 DPI, file size goes down from 2Mb to 150Kb. I'm not sure what you are asking about. – Antonio Jan 7 '18 at 10:38
  • 2
    So it's downscaling the image, using dpi as your scale factor. It isn't actually doing what you think, but the end result is the same - reduction of image dimensions, not actual dpi. dpi is an 'imaginary' figure until you actually lay out a page, then it determines the size in relation to the page. Images have dimensions in pixels; that is the only absolute value. – Tetsujin Jan 7 '18 at 11:07
  • 1
    What steps do you take in preview to convert these images? Is it an automator workflow, print to PDF, export as PDF, something else? Perhaps it's your workflow that could be changed. There is a nice answer using ImageMagic but perhaps you can detail what specific steps you take so that other answers might be possible. – bmike Jan 7 '18 at 15:16
2

ImageMagic

You can use ImageMagick to convert your PNG images to PDFs.

convert -density 100 sample.png sample.pdf

See How can I convert a PNG to a PDF in high quality so it's not blurry or fuzzy? for a related question and answers over on the Unix & Linux site.

Installing ImageMagick and convert

To install the free and open source ImageMagick, and the included convert tool, you can use the Homebrew project.

Once brew is installed, use the following command to install ImageMagick:

brew install imagemagick

Online Services

Alternatively, you can use a web service to perform the conversion for you. Search for convert png to pdf to find such services:

0

The Images to PDF Quick Action here will convert all selected images to one PDF document, without fitting to a page size or resampling the image.

0

Looking for a specialised tool that fits exactly into the workflow described, avoiding some pitfalls other command line options may present, is

img2pdf

Lossless conversion of raster images to PDF. You should use img2pdf if your priorities are (in this order):

  1. always lossless: the image embedded in the PDF will always have the exact same color information for every pixel as the input
  2. small: if possible, the difference in filesize between the input image and the output PDF will only be the overhead of the PDF container itself
  3. fast: if possible, the input image is just pasted into the PDF document as-is without any CPU hungry re-encoding of the pixel data

Conventional conversion software (like ImageMagick) would either:

  1. not be lossless because lossy re-encoding to JPEG
  2. not be small because using wasteful flate encoding of raw pixel data
  3. not be fast because input data gets re-encoded

Another advantage of not having to re-encode the input (in most common situations) is, that img2pdf is able to handle much larger input than other software, because the raw pixel data never has to be loaded into memory.

This is a free/libre and small python tool with minimal dependencies. If you already have pip installed then a simple pip3 install img2pdf takes care of 'getting it'.

Usage is then straightforward:

$ img2pdf img1.png img2.jpg -o out.pdf

Depending on your habits, you type img2pdf in Terminal, you can then select all your PNGs in Finder and just drag&drop them into the Terminal window, add the -oand add the desired name for the output file.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .