You are not logged in.

#1 2013-01-20 20:14:05

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

[SOLVED] Error When Trying to Create PDF from PNGs

I have 30 page-sized PNGs (named 0.png through 29.png) I'm attempting to combine into a single multi-page PDF file. The following ImageMagick command works fine when I use it for fewer pages, but with all 30, it runs for a while and then says "Killed" and fails to output the PDF file. Does anyone have any ideas? Thanks!

[karam@nikolai ~]$ convert -density 300 -compress jpeg 0.png 1.png 2.png 3.png 4.png 5.png 6.png 7.png 8.png ng 21.png 22.png 23.png 24.png 25.png 26.png 27.png 28.png 29.png flash_cards.pdf
Killed

Last edited by tony5429 (2013-01-21 04:01:21)

Offline

#2 2013-01-20 20:38:37

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] Error When Trying to Create PDF from PNGs

Why compress jpegs when there are none?

I would convert the files individually and then combine them using something like pdfjoin (if you have TeX installed) or pdfunite (if you have poppler installed).


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#3 2013-01-20 21:23:09

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

Re: [SOLVED] Error When Trying to Create PDF from PNGs

The -compress jpeg tag tells ImageMagick to use JPEG compression for the images (even though they're coming in as PNGs) - which keeps the final PDFs notably smaller. Thanks for the tips, cfr. I'm trying to stick with IM if possible as this PDF conversion is taking place in a piece of software I'm writing and I'd rather not add another depencency. Does anyone know why IM is failing here? Thanks.

Last edited by tony5429 (2013-01-20 21:23:26)

Offline

#4 2013-01-20 21:29:05

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] Error When Trying to Create PDF from PNGs

That's interesting about the compression. I always assumed it compressed jpegs and would have no effect if I fed it a .png.


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#5 2013-01-20 21:40:25

cfr
Member
From: Cymru
Registered: 2011-11-27
Posts: 7,198

Re: [SOLVED] Error When Trying to Create PDF from PNGs

I found this:

The real problem with using "convert" instead of "mogrify" is that ALL the images are read into memory first! Mogrify takes great pains to only read/modify/write one file (though that file could contain multiple images) at a time. But "convert" does not. As such you can very easily exceed memory limits if you are not careful. Though there are ways around this. See examples in Read Modifiers and Thumbnails.

at http://www.imagemagick.org/Usage/basics/#convert. It does say there are ways around the issue (if that's it).

Last edited by cfr (2013-01-20 21:40:42)


CLI Paste | How To Ask Questions

Arch Linux | x86_64 | GPT | EFI boot | refind | stub loader | systemd | LVM2 on LUKS
Lenovo x270 | Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz | Intel Wireless 8265/8275 | US keyboard w/ Euro | 512G NVMe INTEL SSDPEKKF512G7L

Offline

#6 2013-01-21 04:00:57

tony5429
Member
Registered: 2006-03-28
Posts: 1,025
Website

Re: [SOLVED] Error When Trying to Create PDF from PNGs

Thanks; that's exactly what was happening - running out of memory. I restarted my computer in command-line-only mode (to free up more RAM) and had no issue calling convert.

Offline

Board footer

Powered by FluxBB