convert pdf to png
Carl K
carl at personnelware.com
Mon Dec 24 15:22:34 EST 2007
Grant Edwards wrote:
> On 2007-12-24, Carl K <carl at personnelware.com> wrote:
>
>>> If it is a multi page pdf Imagemagick will do:
>>>
>>> convert file.pdf page-%03d.png
>> I need python code to do this. It is going to be run on a
>> someone else's shared host web server, security and
>> performance is an issue. So I would rather not run stuff via
>> popen.
>
> Use subprocess.
>
> Trying to eliminate popen because of the overhead when running
> ghostscript to render PDF (I assume convert uses gs?) is about
> like trimming an elephants toenails to save weight.
>
maybe, but I wouldn't be so sure.
currently the pdf is created in a python StringIO buffer and returned to the
browser; so it never becomes a file. using convert means I have to first save
it as a file, convert from file to file, read the file, delete the 2 files. so 6
file operations where before there were none. That may be more of a load than
the ghostscript part.
Carl K
More information about the Python-list
mailing list