Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImageMagick using more than 2GB of memory to convert PDF files

ImageMagick is using huge amounts of memory to convert PDF files - more than 2GB. The command I'm using is:

convert -density 250 -resize 1280x myfile.pdf -interlace plane -strip -quality 40 -alpha flatten myfolder/myfile-%03d.jpg

How can this be improved? I have an 1GB limit or else the process is killed ruthlessly. ):

like image 352
MaiaVictor Avatar asked Mar 13 '13 12:03

MaiaVictor


People also ask

How do I convert a 2GB PDF to 1280x 1280x?

ImageMagick is using huge amounts of memory to convert PDF files - more than 2GB. The command I'm using is: convert -density 250 -resize 1280x myfile.pdf -interlace plane -strip -quality 40 -alpha

What are the limits of ImageMagick?

By default the limits are 768 files, 3GB of image area, 1.5GiB memory, 3GiB memory map, and 18.45EB of disk. These limits are adjusted relative to the available resources on your computer if this information is available. When any limit is reached, ImageMagick fails in some fashion but attempts to take compensating actions, if possible.

How do I convert a PDF file to an image?

There is a quick and convenient way to convert PDF to one or more images. Command line tool ImageMagick does that (and a lot more). You can convert an entire PDF document to a single image, or, if you like, there is an option to output pages as a series of enumerated image files.

Is it possible to use ImageMagick/Tesseract OCR with PHP?

My company is moving away from using an application called SimpleIndex that could OCR files for scanned images. I'm testing ImageMagicK/Tesseract OCR (hopefully with PHP to get the job done). Initially, we have a PDF that has several scanned images combined together. I then use this command line to use ImageMagicK to convert the PDF file to a TIF.


1 Answers

Use the memory limit option.

Option usage shown here:

http://www.imagemagick.org/script/command-line-options.php#limit

-limit type value

Set the pixel cache resource limit.

Choose from: area, disk, file, map, memory, threads, or time.

The value for file is in number of files. The other limits are in bytes. Define arguments for the memory, map, area, and disk resource limits with SI prefixes (.e.g 100MB).

By default the limits are 768 files, 3GB of image area, 1.5GiB memory, 3GiB memory map, and 18.45EB of disk. These limits are adjusted relative to the available resources on your computer if this information is available. When any limit is reached, ImageMagick fails in some fashion but attempts to take compensating actions, if possible. For example, the following limits memory:

-limit memory 32MiB -limit map 64MiB

like image 118
Randy Howard Avatar answered Oct 27 '22 04:10

Randy Howard