ImageMagick's `convert` utility takes *too much* memory with PDF input

Solution 1:

I am using the following:

convert -limit memory 64 -limit map 128 original.djvu newfile.pdf

My main drive has limited space, so I prepend a variable

env MAGICK_TMPDIR=/host/Temp convert -limit memory 64 -limit map 128 original.djvu newfile.pdf

Solution 2:

Solved with the following:

cat <<EOF > /etc/profile.d/
# Set ImageMagick memory limits: it eats too much
export MAGICK_MEMORY_LIMIT=1024 # Use up to *MB of memory before doing mmap
export MAGICK_MAP_LIMIT=1024    # Use up to *MB mmaps before caching to disk
export MAGICK_AREA_LIMIT=4096   # Use up to *MB disk space before failure
export MAGICK_FILES_LIMIT=1024  # Don't open more than *file handles

Solution 3:

Have you tried cache?

From the man page

-cache threshold

      megabytes of memory available to the pixel cache.

      Image pixels are stored in memory until 80 megabytes of
      memory have been consumed.  Subsequent pixel operations

      are cached on disk.  Operations to memory are  significantly 
      faster but if your computer does not have a sufficient 
      amount of free memory you may  want  to  adjust
      this threshold value.