I want to convert a Python Turtle module (tkinter) canvas into a bitmap. I have followed the suggestion at "How to convert a Python tkinter canvas postscript file to an image file readable by the PIL?" to convert it first to postscript; then I open it as a PIL image, then save that as a bitmap. But the bitmap is a different size from the original canvas.
import turtle
import io
from PIL import Image
myttl = turtle.Turtle()
wd=500
ht=500
turtle.setup(width=wd, height=ht, startx=0, starty=0)
turtle.mode('logo') # start pointing north
myttl.forward(100)
screen = turtle.Screen()
cv = screen.getcanvas()
ps = cv.postscript(colormode='mono')
img = Image.open(io.BytesIO(ps.encode('utf-8'))).convert(mode='1')
img.save('test.bmp')
In the above code, the canvas is 500x500. But the file test.bmp is shrunk to 374x374, and its image is smaller than the on-screen turtle graphic. How can I get an unshrunk 500x500 bitmap?