Page 1 of 1
append without degradation
Posted: 2012-09-05T11:04:16-07:00
by dzieglerok
I have a simple problem. I have multipage pdf files that I need to convert to a single page long, vertical tiff file. I successfully do this easily but while doing so, the image degrades an unacceptable amount no matter what I do.
convert "file1.pdf" -append "file1.tif"
Any help would be appreciated.
I can send an example file...
thanks in advance.
Re: append without degradation
Posted: 2012-09-05T11:50:42-07:00
by whugemann
You have to set the resolution before reading the PDF. Furthermore you should set some compression format in order to reduce the size of the output file. So your command should be something along the lines of:
convert -density 254 test.pdf -append -compress zip test.tif
Re: append without degradation
Posted: 2012-09-05T12:08:09-07:00
by dzieglerok
Wolfgang,
That worked. Now can I batch process about 30 of these files? Each are pdf's that are named differently and all in one directory.
Thanks a million. I owe you lunch...
Re: append without degradation
Posted: 2012-09-06T01:43:17-07:00
by whugemann
You could either use Mogrify instead of Convert with a filename template or loop through the files by a script or OS command. How exactly you perform the latter depends on you operating system, which you didn't tell. Examples under Windows can be found at the link below.
Re: append without degradation
Posted: 2012-09-06T13:06:50-07:00
by dzieglerok
Dear Wolfgang,
Here is my script:
montage -density 254 "Bankers Black Sonic Log.pdf" -mode concatenate -tile 1 "Bankers Black Sonic Log.tif"
or
convert -density 254 "Apollo Watson D-N Log.pdf" -append "Apollo Watson D-N Log.tif"
Each original file is 12-15 MB. I watched system resources and the Ram used exceeded 1.6GB. The process brings my win32 with 3GB Ram to its knees. I have 4 I7 dual processors running at 2.67 GHz. (Gateway). The CPU varies from 1-12% staying mostly low. It is also heavily using I/O.
I can't wait this long for each file to complete. Is there a less intensive way to do this. This is not a complicated process. I am just stiching images together.
I can send you one of the files to give it a try...
Thanks in advance,
Dan
Re: append without degradation
Posted: 2012-09-06T17:19:20-07:00
by anthony
You must remember IM when handling PDF files is calling another program to do this very complex task .. Ghostscript
You can try and use ghost script directly, which will avoid a lot of extra file handling IM has to do due to security concerns. See Using GhostScript Directly
http://www.imagemagick.org/Usage/text/#ghostscript
Ghostscript can output directly to TIFF file format, though to append you can still feed IM.
The ideal soltuion would be to get ghostscript to output a stream of images (ppm format), then have IM read and append the stream (pipeline) and output the final result. this will avoid all the intermediate disk I/O, that would have been slowing your previous usage.
Something like (psuedo-code)
Code: Select all
for each image
ghostscript image, output PPM images to stdout
end | convert ppm:- +append final.tif
This technique is used in an number of IM example (though not with ghostscript).
For a simple example using MIFF image stream, rather than PPM...
http://www.imagemagick.org/Usage/files/#miff_stream