recomendations to improve speed?

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
rgwillia

recomendations to improve speed?

Post by rgwillia »

I am trying to automate a process that takes a print job in PostScript format and converts it to a tiff image. The standard "convert image.ps image.tiff" is not nearly high enough quality to read. The files are scanned in B&W documents (no greyscale needed) that were sent via a print job to a server that saved them in PS format. I found that I needed to increase the density to around 200 to be able to read the documents. Each document is between 10 and 20 pages. The desired file size is less than 1mb. (we have other applications that use similar files that are easily able to accomplish this with tiff images)

I am new at this but here is my command so far.

convert -density 200 image.ps -colorspace GRAY -monochrome -compress Group4 image.tiff

The PostScript file is about 9mb and the output file is about 0.5mb. Each file is taking about 6min to process and I will have upwards of 300 of these to process each day. Unless I find a way to get myself 30 hours in a day I need to do someting to speed this process up.

The machine running the conversion is a fairly high speed machine and the OS is hosted in a VMWare ESX virtual machine Running Suse 10.2 using ImageMagick 6.3.0.
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: recomendations to improve speed?

Post by magick »

Try the following command:
  • convert -limit area 4096 -limit memory 4096 -density 200 -monochrome +antialias image.ps -compress Group4 image.tiff
You might get some additional speed improvements with the latest ImageMagick release, 6.3.2-9.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: recomendations to improve speed?

Post by anthony »

As for quality improvements all you can do is use an even higher density, however that will make it at least a square slower (double density is 4 times the memory requirements) for both IM and the ghostscript delegate.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rgwillia

Re: recomendations to improve speed?

Post by rgwillia »

anthony wrote: As for quality improvements all you can do is use an even higher density, however that will make it at least a square slower (double density is 4 times the memory requirements) for both IM and the ghostscript delegate.



I do not need much more in the way of quality improvements. I mainly need speed improvements. I tested an application on a windows box that only took seconds to do almost the exact same thing. (except that it broke it into individual 1 page tiff files).
User avatar
magick
Site Admin
Posts: 11064
Joined: 2003-05-31T11:32:55-07:00

Re: recomendations to improve speed?

Post by magick »

Try using Ghostscript directly to convert your image and bypass ImageMagick. Ghostscript has a TIFF device you can use to convert Postscript to TIFF.
rgwillia

Re: recomendations to improve speed?

Post by rgwillia »

Try using Ghostscript directly to convert your image and bypass ImageMagick.


Can you point me in the right direction here? I don't see any actual CLI applications as part of ghostscript, just a library.
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: recomendations to improve speed?

Post by anthony »

See the adendium in IM Examples Text to Image handling, Postscript
http://www.imagemagick.org/Usage/text/#postscript

At the very end of that section just before 'Draw'.
---------------
ASIDE: Using Ghostscript directly...
While this not strictly IM, Richard Bollinger have reported that running the "ghostscript" delegate directly is much more efficient.

For example instead of running...

Code: Select all

    convert -density 300x300 -compress Group4 file.ps  file.tif
You can get ghostscript to do it directly.

Code: Select all

    gs -sDEVICE=tiffg4 -r300x300 -dNOPAUSE -sOutputFile=file.tif \
       file.pdf 
This prevents the need for IM to generate a large temprorary file, and quite a lot of extra time.

However "ghostscript" can not resize the resulting image, and may not have the image format you specifically require. It can also be a difficult program to figure out how to use, as it is designed to be used by other programs and not directly by users.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
rgwillia

Re: recomendations to improve speed?

Post by rgwillia »

Wow,

That was MUCH faster. It only takes about 3/4 of a second instead of 3mins using imagemagick. It also appears to be about the same quality and size. The only thing I need to figure out now is why it is dropping me into a "GS>" prompt instead of back to command line. Off to read the man page!
rgwillia

Re: recomendations to improve speed?

Post by rgwillia »

I am just posting to reply to my own message here incase anyone needs the answer in the future. If you don't want the GS> prompt you must use the option -dBATCH. The full command that I used was:

/usr/bin/gs -dBATCH -dNOPAUSE -sDEVICE=tiffg4 -r200x200 -sOutputFile=file.tiff file.ps
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: recomendations to improve speed?

Post by anthony »

I applogies by the HTML did not show the "</dev/null" that was on the end of the 'gs' example. however the -dBATCH is probably a better method.

I have updated the example, give it a day or so to appear on the IM main site.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
RXGX

Re: recomendations to improve speed?

Post by RXGX »

Would it be faster if I had GS perform the PDF to TIF conversion in the following code?

Code: Select all

convert -density 300 -units PixelsPerInch -profile cmyk.icc -profile srgb.icm {$name}.pdf -resample 72x72 {$name}.tif
convert {$name}.tif -quality 100 -resize 244x {$name}-thumb.jpg
convert {$name}.tif -quality 100 {$name}-large.jpg
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: recomendations to improve speed?

Post by anthony »

It would probably improve the speed to DIY.

however ghostscript is not easy to use. here is what cristy has said in the past...
If ghostscript had one robust device to handle RGB, RGBA, CMYK, and CMYKA image types (RGB and CMYK with and without transparency) ImageMagick would be able to render Postscript to an image format quite robustly. However, ImageMagick has to select from different devices based on what it sees in the Postscript document. It chooses the device conservatively to ensure the conversion is proper for a great majority of Postscript documents.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply