FW: Printing images through Python

T

Tim Golden

From: Kevin [mailto:eek:[email protected]]
Sent: 04 October 2003 03:21
To: (e-mail address removed)
Subject: Re: Printing images through Python

Thanks for the help Tim, seems to work well!

Only too glad I could save someone the hours of frustrating
search it took me to get that far.
One problem I had though, just FYI:
turned out that printer_resolution[1] was a
function... have to do more looking to figure out why.

Blowed if I can see why; it's just the return value from GetDeviceCaps.
Ah... looking at my email to you underneath yours to me, the line has
been chopped (hope this makes it across the email systems) thus:

printer_resolution [...] = hDC.GetDeviceCaps [unintended line break]
(VERTRES)

which will make Python think that the second value in
the printer_resolution tuple is the function GetDeviceCaps
and that the (VERTRES) is merely a throwaway value.
It should, of course, read:

[...] = hDC.GetDeviceCaps (VERTRES)

where VERTRES is the parameter to GetDeviceCaps
I just used [0] for both args and it was fine(for now).

That'll work because, in any case, the code later on takes
the smaller of the two ratios to determine the scaling factor,
and printer_resolution[0] is the width of the page, which
is going to be the smaller of the two anyway.

Hope it works out for you. I haven't yet bothered to go
into using the Printer Setup dialogue, which truly is a
pain. I'm using a Pygame interface, so I'm trying to cut
down on Windows-esque dialog boxes.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
 
K

Kevin

Thanks for the follow-up Tim, I caught that error after cleaning my glasses.
:)

I've managed to expand on your example to write a stand-alone module for
handling printing PIL images on Windows. Interfacing to the standard
Windows printer-setup dialog is beyond me for now, so if you have ANY
suggestions I'd appreciate it!

I'm planning on includinga simple GUI class that handles
sizing/margins/etc., but the standard dialogs would be better (and fuller
functionality).

You can try the first "test" version of the module at (and I'd appreciate
some independent testing to make sure it works with many printer setups):

http://www.cazabon.com/python/downloads/WinPILprint.py

However, I'll be releasing a much updated version under a different name in
the next few days (ImagePrintWin, to follow the PIL module naming convention
a little better... hopefully I can convince Fredrik to include the final
version with the standard PIL dist.)

(Thanks again!)

Kevin.

Tim Golden said:
From: Kevin [mailto:eek:[email protected]]
Sent: 04 October 2003 03:21
To: (e-mail address removed)
Subject: Re: Printing images through Python

Thanks for the help Tim, seems to work well!

Only too glad I could save someone the hours of frustrating
search it took me to get that far.
One problem I had though, just FYI:
turned out that printer_resolution[1] was a
function... have to do more looking to figure out why.

Blowed if I can see why; it's just the return value from GetDeviceCaps.
Ah... looking at my email to you underneath yours to me, the line has
been chopped (hope this makes it across the email systems) thus:

printer_resolution [...] = hDC.GetDeviceCaps [unintended line break]
(VERTRES)

which will make Python think that the second value in
the printer_resolution tuple is the function GetDeviceCaps
and that the (VERTRES) is merely a throwaway value.
It should, of course, read:

[...] = hDC.GetDeviceCaps (VERTRES)

where VERTRES is the parameter to GetDeviceCaps
I just used [0] for both args and it was fine(for now).

That'll work because, in any case, the code later on takes
the smaller of the two ratios to determine the scaling factor,
and printer_resolution[0] is the width of the page, which
is going to be the smaller of the two anyway.

Hope it works out for you. I haven't yet bothered to go
into using the Printer Setup dialogue, which truly is a
pain. I'm using a Pygame interface, so I'm trying to cut
down on Windows-esque dialog boxes.

TJG

________________________________________________________________________
This e-mail has been scanned for all viruses by Star Internet. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top