wx.Image(postscript)

Hi all,

is there any way how to convert a postscript file to image format
readable by wx.Image directly in wxPython without e.g. Python Image
Library?

Thanks, Martin

···

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

Martin Landa wrote:

is there any way how to convert a postscript file to image format
readable by wx.Image directly in wxPython without e.g. Python Image
Library?

No, and even PIL won't do that. It will create Postscript, but it won't
read it.

Postscript is essentially a computer language (it's a version of Forth);
interpreting it requires a compiler. The only practical open source
Postscript interpreter is Ghostscript. You will need a product that has
Ghostscript embedded in order to handle a Postscript file.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

I meat this - sample code

            file = <postscript file>
            im = Image.open(file)
            im.save(img)

            image = wx.Image(img, wx.BITMAP_TYPE_PNG)

which works. Martin

···

2011/3/29 Tim Roberts <timr@probo.com>:

Martin Landa wrote:

is there any way how to convert a postscript file to image format
readable by wx.Image directly in wxPython without e.g. Python Image
Library?

No, and even PIL won't do that. It will create Postscript, but it won't
read it.

--
Martin Landa <landa.martin gmail.com> * http://geo.fsv.cvut.cz/~landa

Martin Landa wrote:

I meat this - sample code

            file = <postscript file>
            im = Image.open(file)
            im.save(img)

            image = wx.Image(img, wx.BITMAP_TYPE_PNG)

which works.

My mistake. PIL does include a version Ghostscript. I should have
tried it myself instead of trusting my friend Google.

wx does not include Ghostscript. There is an add-on called
wxGhostscript that will let you interpret Postscript files, but it
requires that you have a version of Ghostscript already installed. PIL,
in my opinion, is a better solution.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Take a look at http://www.swftools.org/gfx_tutorial.html

Gadget/Steve
···

On 28/03/2011 11:14 PM, Tim Roberts wrote:

Martin Landa wrote:
is there any way how to convert a postscript file to image format
readable by wx.Image directly in wxPython without e.g. Python Image
Library?

No, and even PIL won't do that. It will create Postscript, but it won't
read it.
Postscript is essentially a computer language (it's a version of Forth);
interpreting it requires a compiler. The only practical open source
Postscript interpreter is Ghostscript. You will need a product that has
Ghostscript embedded in order to handle a Postscript file.

Sorry, folks. All the PIL documentation I’ve ever seen specifically says it can’t read either PS or PDF files, but can write them.

Ray Pasco

Ray Pasco wrote:

Sorry, folks. All the PIL documentation I've ever seen specifically
says it can't read either PS or PDF files, but can write them.

But that's not correct, as Martin pointed out. PIL can read and convert
Postscript files, because it includes Ghostscript.

Apparently it cannot do PDFs -- I just tried that.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Well no surprise there. The Docs for PIL haven’t been updated in over 2 years.

  • Mike

I don’t care what he said. This is available only on certain platforms (included with PIL on Ubuntu ?).
Writing doesn’t work on MSW platforms.
Reading invokes the Ghostscript executable with a command line that’s not suitable for MSW, but I think that’s easily changed.
def Ghostscript(tile, size, fp):
“”“Render an image using Ghostscript (Unix only)”""

Ray Pasco wrote:

I don't care what he said. This is available only on certain platforms
(included with PIL on Ubuntu ?).

Writing doesn't work on MSW platforms.

Reading invokes the Ghostscript executable with a command line that's
not suitable for MSW, but I think that's easily changed.

I didn't try writing (I have Acrobat for that), but I certainly DID try
reading, because I dared to doubt him. It worked perfectly, straight
out of the box.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Your platform ?

Ray Pasco wrote:

Your platform ?

XP SP3, Python 2.6, wxPython 2.8.10.

···

--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.