How to create pdf from images (.png, .jpg, etc...) ?

All Gurus once were Newbies
Forum rules
There are no such things as "stupid" questions. However if you think your question is a bit stupid, then this is the right place for you to post it. Please stick to easy to-the-point questions that you feel people can answer fast. For long and complicated questions prefer the other forums within the support section.
Before you post please read how to get help
Post Reply
ecryptfs
Level 1
Level 1
Posts: 11
Joined: Sun Aug 14, 2016 6:13 am

How to create pdf from images (.png, .jpg, etc...) ?

Post by ecryptfs » Wed Feb 22, 2017 9:12 pm

Hello,
i have a lot of .png images i would like to merge into one .pdf file, one image per page and with the same starting quality (or almost).
Is there any good software suggested or anything that i can do through command line to reach my goal? Oh, i have no experience in this field.


Thank you in advance :)
Last edited by ecryptfs on Wed Feb 22, 2017 9:53 pm, edited 2 times in total.

User avatar
MintyO
Level 4
Level 4
Posts: 460
Joined: Mon Apr 11, 2011 2:54 pm

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by MintyO » Wed Feb 22, 2017 9:35 pm

Well I don't do a lot of stuff with images, but I just tried the solution I use with web pages. You open your pictures with some program and print them, choose "print to file option" (default format is pdf). I tried this with 3 pictures and pix.
Ducks on the edge sleep with one eye open.

User avatar
InkKnife
Level 5
Level 5
Posts: 728
Joined: Mon Apr 30, 2012 5:24 pm

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by InkKnife » Wed Feb 22, 2017 11:31 pm

The word you are looking for is "concatenate". I have never had to do this myself but looks like there is a lot of info out their.
Time to put your reading glasses on :)

https://www.google.com/search?q=concato ... +pdf+pages
i7 3770, 12GB of ram, 256GB SSD, 64GB SSD, 750GB HDD, 1TB HDD, Cinnamon.

all41
Level 15
Level 15
Posts: 5702
Joined: Tue Dec 31, 2013 9:12 am
Location: Computer, Car, Cage

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by all41 » Thu Feb 23, 2017 12:00 am

I would use Libre Office Impress to add images and then export the entire presentation as pdf.

User avatar
BenTrabetere
Level 6
Level 6
Posts: 1030
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by BenTrabetere » Thu Feb 23, 2017 1:54 am

I would use the ImageMagick Convert tool. It is run from the command line and it is case-sensitive.

To combine several individual images into a single pdf.

Code: Select all

convert file1.jpg file2.jpg file3.jpg output.pdf
To combine every png image in the current directory into a single pdf.

Code: Select all

convert *.png output.pdf

Turtletronic
Level 1
Level 1
Posts: 40
Joined: Sun Sep 11, 2016 8:04 am

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by Turtletronic » Thu Feb 23, 2017 4:37 am

I simply use the image archive/thumbnail/conversion software "XNViewMP" (DEB or TGZ available via their website http://www.xnview.com/en/xnviewmp/). It supports creating multi-page PDFs from images via CREATE -> MULTI PAGE FILE. The program appears pretty much function-overloaded at first but seeing how bad Linux-own image software (gThumb and others) compare I rather kicked umpteen useless tools in fav of ONE tool that really works, regardless of used desktop environment or even distro.
My music library includes 57,139 tracks. My advice? Forget Amarok, Banshee, Clementine or Rhythmbox.

fabien85
Level 7
Level 7
Posts: 1582
Joined: Tue Mar 11, 2014 4:30 pm

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by fabien85 » Thu Feb 23, 2017 10:07 am

Command line is always the fastest, BenTrabetere's solution is the best in my opinion.
I was going to suggest a slightly longer solution : first convert each image in a pdf with convert, then concatenating the pdf's with pdftk :

Code: Select all

pdftk *.pdf cat output output.pdf
(pdftk is available in the repositories, so you can install it with the software manager, or apt, synaptic ...)
I didnt know convert could also concatenate the files, which skips one step and makes it easier.

pdftk is an excellent tool to work with pdfs, it can concatenate, split, merge, encrypt, rotate, repair .. them.

User avatar
phd21
Level 19
Level 19
Posts: 9514
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by phd21 » Thu Feb 23, 2017 12:11 pm

Hi "ecryptfs",

I just read your post and the good replies to it. Here are my thoughts on this as well.

FYI: Console Terminal commands tend to be quicker.

"Master PDF Editor" works. Create a new PDF document, select number of pages that equal the number images you want to use, then on the first page click image, click the page, select image and resize image if you want, scroll down or page down to next page, click image, click that page, select image and resize if you want, and repeat the process, when done, just save the PDF document.

LibreOffice products (as was already mentioned), like LibreOffice Writer as well.

"Scribus"

FYI: Once the images are converted to PDF, then there are various commands, including copy (cp) to concatenate (add) them into one PDF.

"Converseen" might work as well, it can convert images to pdf.

How about using "pdfchain" the desktop front-end to "pdftk"? It looks like it could work, but first time I ever used it. I ran a quick test on this with some images, but I could not get it to work, but that does not mean that it could not work.

"sam2p" - command. Install from Software Manager or Synaptic Package Manager (SPM)

Hope this helps ...
Last edited by phd21 on Thu Feb 23, 2017 9:26 pm, edited 1 time in total.
Phd21: Mint 19.2 Cinnamon & xKDE (Xfce) & KDE Neon 64-bit Awesome OS's, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram, 256gb SDD, only Intel 4 Graphics. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

User avatar
BenTrabetere
Level 6
Level 6
Posts: 1030
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by BenTrabetere » Thu Feb 23, 2017 12:58 pm

A follow up to using IM Convert to create a multi-page PDF from several image files.

One of the last steps in my photography workflow is to create two PDFs. The first is a contact sheet - a single page of thumbnails suitable for reviewing all of the images quickly. The other is a multi-page PDF "slideshow".

The "slideshow" can be very large. It does not take many high-resolution JPGs to end up with a massive PDF - it is my experience that it will be slightly smaller than the combined size of the source files. A recent shoot I had 35 images, and the high-resolution JPGs weighed in at 489MB. The resulting PDF slideshow took nearly four minutes to generate and weighed in at a whopping 460MB, and it was simply too large to work with.

I intend for my PDF slideshows to be viewed on a monitor. Prints are made from the high-resolution JPGs and TIFFs. To get a more manageable slideshow I reduce the quality of the images - the image quality is still good enough for viewing and it is is much more friendly on system resources. When I generate the same slideshow but with the resolution reduced 75%, it gave me a 36MB PDF in just under 2 minutes, and the PDF viewers I used did not complain about the load.

Code: Select all

convert *.jpg -resize 25% output.pdf

User avatar
phd21
Level 19
Level 19
Posts: 9514
Joined: Thu Jan 09, 2014 9:42 pm
Location: Florida

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by phd21 » Thu Feb 23, 2017 1:57 pm

Hi Everyone in this post's thread,

I am curious about why anyone would want to convert images to PDF format, could any of you explain to me why you would do that?

For a quality presentation to anyone, you can use any of the "slideshow" (movie maker) applications (FFdiaporama, imagination, videoporama, etc...), or one of the many video editors for that matter (Kdenlive, Lives, Lightworks, Openshot, Pitivi, etc....).
Phd21: Mint 19.2 Cinnamon & xKDE (Xfce) & KDE Neon 64-bit Awesome OS's, Ancient Dell OptiPlex 780 Core2Duo E8400 3GHz,4gb Ram, 256gb SDD, only Intel 4 Graphics. Why I use KDE?:https://opensource.com/life/15/4/9-reasons-to-use-kde

ecryptfs
Level 1
Level 1
Posts: 11
Joined: Sun Aug 14, 2016 6:13 am

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by ecryptfs » Thu Feb 23, 2017 4:47 pm

Well, first of all thanks for all the answers.

As fas as i can see pdfchain works with pdfs only and not with image files. I will keep it anyway for any future use.

I think that "convert" should be the perfect way, so i made some tests with:

Code: Select all

convert *.png output.pdf
The first test went fine and the output was perfect
I tried again on the same files but on different folder and i start getting a lot of errors, like:

Code: Select all

convert: IDAT: CRC error `26 - 29.png' @ error/png.c/MagickPNGErrorHandler/1645.
convert: corrupt image `26 - 29.png' @ error/png.c/ReadPNGImage/3978.
convert: Ignoring bad adaptive filter type `27 - 30.png' @ warning/png.c/MagickPNGWarningHandler/1671.
And i noticed that i can't open the original image anymore because it say it is corrupted.
I made another test, first i checked if i could open images, they were ok. I gave the command, same errors and again could not open images like if they got corrupted during the process. Since the second test i'm not able to successfully convert anymore :?

About sam2p i'm still trying to learn how it works. I managed to convert one image only to pdf, but not yet all at same time.

User avatar
BenTrabetere
Level 6
Level 6
Posts: 1030
Joined: Sat Jul 19, 2014 12:04 am
Location: Hattiesburg, MS USA

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by BenTrabetere » Thu Feb 23, 2017 9:06 pm

ecryptfs wrote:I tried again on the same files but on different folder and i start getting a lot of errors, like:
There is a utility called pngcheck that verifies the integrity of PNG files. I suggest you run it against these "corrupt" PNGs to see what is wrong. The error I see most frequently is file doesn't end with an IEND chunk, and ImageMagick refuses to work with these files.

You can install it from Software Manager or from the command line using

Code: Select all

sudo apt install pngcheck
The syntax for pngcheck is pngcheck filename.png. If the images are corrupt (a sure bet if ImageMagick is throwing errors), open these files in an image editor like GIMP, save them, and then run pngcheck again.

ecryptfs
Level 1
Level 1
Posts: 11
Joined: Sun Aug 14, 2016 6:13 am

Re: How to create pdf from images (.png, .jpg, etc...) ?

Post by ecryptfs » Fri Feb 24, 2017 2:51 pm

Well, strange things happen sometimes.
After rebooting my computer everything was fine and i could convert all images with "convert" command without any issue.
Since they are scanned images, is it possible that some process was still active and corrupt them while trying conversion?
So, "convert" does his job pretty well and i will stick with it.
Thanks for the pngcheck tip too, i gladly installed and used it.
:)

Edit: i have made some tests. If i scan something, save it to .png, run pngcheck it will show as corrupted. If after saving i reboot computer, then i run pngcheck and it's fine.

Post Reply

Return to “Newbie Questions”