Question: How can I merge several `.png` files into one PDF file in Unix?

Answer: 
From looking through the documentation on ImageMagick, it might be as easy as:

```
convert 1.png 2.png myfile.pdf

```

See comments about possible risks. If that doesn't work, [PDFjam](http://www2.warwick.ac.uk/fac/sci/statistics/staff/academic-research/firth/software/pdfjam) claims to be able to solve your problem.
**ImageMagick**’s [***convert***](http://www.imagemagick.org/script/convert.php) tool is my preference.

> 
> The convert program is a member of the ImageMagick suite of tools.
> Use it to convert between image formats as well as resize an image,
> blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.
> 
> 
> 
> ```
> convert [input-option] input-file [output-option] output-file`
> 
> ```
> 
> 

If you want the image files (and thus, their quality and file size) unaltered, and just put a PDF container around them:

```
convert In.png In-2.png Someother-*.png Result.pdf

```

In case you want to have a smaller file size, and you are okay with a loss in quality, you can convert them to the JPEG format first. (ImageMagick also supports changing the PNG compression level, but usually your input files are already using the highest level.)

```
convert 1.png 2.png -compress jpeg -quality 50 Result.pdf

```

Use a value between 0 and 100 for the [`quality`](http://www.imagemagick.org/script/command-line-options.php#quality) option.

Alternatively, you can reach a lower file size (and quality) by resampling the images to a certain resolution.

```
convert *.png 2.png -resample 300 Result.pdf

```

The value for [`resample`](http://www.imagemagick.org/script/command-line-options.php#resample) refers to the number of pixels per inches. ImageMagick reads the original density from EXIF part of the input images, falling back to 72 dpi. You can use the [`density`](http://www.imagemagick.org/script/command-line-options.php#density) parameter to set a custom resolution for the input images.

You can of course also combine the `compress`, `quality`, and `resample` parameters.