1

I've 415 gif files in a directory and trying to make a single pdf of them by using the following command:

convert /path/to/*.gif file.pdf

But it cause for hanging/freezing of the entire system. In other words it makes the system very slower and I've to Ctrl+c (kill) the process (which also consume some time for stopping).

How do I face this issue/problem? Is there any better/alternative mechanism (command/program/work-around) for doing this task?

Note: I'm working on my simple Desktop PC (3+3 GHz P4 processor and 1GB og RAM) with Trisquel GNU/Linux 7.0 LTS. The convert program is a member of the ImageMagick suite of tools.

2

You are probably using a lot of ram and causing swapping. A simple test using /usr/bin/time -v in front of the command when run on say 5 files, and again on 10 files will show that the Maximum resident set size is approximately double for twice as many files.

So rather than doing them all at once, convert them one at a time, or say ten at a time, then concatencate the pdfs. It will take longer, but less memory.

rm -f /tmp/file.pdf
for i in *.gif
do convert "$i" /tmp/a.pdf
   if [ -s /tmp/file.pdf ]
   then gs -q -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=/tmp/b.pdf /tmp/file.pdf /tmp/a.pdf
   else mv /tmp/a.pdf /tmp/b.pdf
   fi
   mv /tmp/b.pdf /tmp/file.pdf
done
  • Hmm.. watch du -h /tmp/[a,b,file.pdf] shows the movie written by you! – Pandya Nov 21 '16 at 16:36
  • Consider use convert -coalesce for faster and better pdf. – 林果皞 Nov 21 '16 at 16:48
0

Use cpulimit and ionice and nice:

nice -n19 ionice -c3 cpulimit -l 20 -- convert /path/to/*.gif file.pdf
  • Can you provide a bit information about nice, ionice and the arguments you've provided with them? (I think it would be about prioritizing) – Pandya Nov 21 '16 at 7:29
  • whatis nice nice (1) - run a program with modified scheduling priority, whatis ionice ionice (1) - set or get process I/O scheduling class and priority, whatis cpulimit cpulimit (1) - limits the CPU usage of a process Feel free to install them, the package names are the same as command names. – Ipor Sircer Nov 21 '16 at 7:33
  • @IporSircer This answer is not only careless, it addresses the OPs question only very remotely. – countermode Nov 21 '16 at 7:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.