Skip to content

PSDraw.rectangle produces incorrect PostScript #6428

@mrabarnett

Description

@mrabarnett

This code should draw a rectangle, but it produces a blank page:

from PIL import PSDraw

with open('output.ps', 'wb') as file:
    ps = PSDraw.PSDraw(file)
    ps.begin_document('TEST')
    ps.rectangle((1 * 72, 4 * 72, 3 * 72, 2 * 72))
    ps.end_document()

I inspected the PostScript that it produced and it didn't make a whole lot of sense to me (I've worked with it in the past) until I realised that the parameters on the PostScript stack were in the wrong order.

The PostScript says "72 288 M 216 144 0 Vr" when it should say "72 288 M 0 216 144 Vr", i.e. it's "left top M width height 0 Vr" instead of "left top M 0 width height Vr".

When I edited the PostScript, I got the expected result.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugAny unexpected behavior, until confirmed feature.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions