Closed josal closed 11 years ago
Hi,
You could use rghost calling each image in the beginning of the page. But, for such behaviour I'd suggest to use convert
command from imagemagick toolkit, it will be easy and faster, for instance:
convert image1.jpeg image2.jpeg imageN.jpeg output.pdf
Thanks for the answer,
I'll try the convert command, however, I've been using rmagick from ruby and it consumes a huge amount of memory (in heroku it throws R14 errors for medium-size files!).
I'll come back to you with the results. Thanks again
I've just done the test, and R14 errors are still there. It seems the process is greater than 512MB in memory.
Maybe could I do it progresivelly, not once in a time?
Thanks again for your comments
Are you using command line or rmagick to get it done? By command line, it's the best way, you could use it by syste() or surround the command by pop3.
I've used the system() method with your convert command. With rmagic it gave me the errors I told you.
What is this pop3?
I meant popen3.
Ok, I will try to wrap the call with popen3. However, it seems the process gets until 1,5GB in memory (it's what heroku says), so the problem is not related to rmagick (I thought), because with the convert
command line ghostscript system call it gets a similar amount of memory for a not very big 14-images pdf file (really!!!, R14 errors gives me this information).
I have to try rghost, pdf::writer or prawn in order to open each page and insert there each image...
Do I have other options?
Have you ever tried -limit
(aka '-cache') to set the max of memory?
http://www.imagemagick.org/script/command-line-options.php#limit
I thought yesterday you had given to me the final solution. Many thanks man.
This is the command I'm using in ruby:
system("convert -limit memory 32MiB -limit map 64MiB #{jpg_list.join(" ")} #{final_file.pdf}")
It gives only R14 errors with certain big jpg_lists (40, 100 images), but for others thay have dissappeared.
I these cases, it gets all the available memory (if I hire a 512 MB worker, it gets the whole space, if I hire a 1024 MB worker, tha same thing) - so, it seems like the limit is not been considered.
How can I know the memory limits which have been set in the process?
If I specify -limit memory 0 -limit area 0
, no R14 error appears. So, I think I found the solution at last.
Thanks for your answers and suggestions.
Kind regards.
Hi,
I've been using rghost for some weeks and it works great, thanks for the gem.
I need to create a PDF file from some images. Could I call a method to do it in batch or I have to create every page programatically including the proper image where it corresponds (at the beginning of the page)?
Thanks in advance for your help.