问题
So I have created the following save function for my turtle graphics program to allow the user to save the canvas as a .png file with its own file name:
def savefirst():
cnv = getscreen().getcanvas()
ps = cnv.postscript(colormode = 'color')
hen = filedialog.asksaveasfilename()
print(hen)
im = Image.open(io.BytesIO(ps.encode('utf-8')))
im = im.resize((2560, 1600), Image.ANTIALIAS)
quality_val = 95
sharp = ImageEnhance.Sharpness(im)
sharp.enhance(2.0).save(hen + '.png', 'PNG')
However, if the user were to set the background to a different color, in the output file (.png) the background color does not appear. Also, the output image gets VERY rough around curves. Below is what I mean, according to a screenshot of the canvas itself comparing it to the saved output:
Screen shot of Canvas itself:
Saved Output:
How would I fix these issues, preferably somehow using the Python Imaging Library? If that is not possible, is there ANY other way for me to save my canvas as a jpeg so that EVERYTHING comes out flawless (just as a screenshot, i.e. with ALL the colors and NO distortions)? Any help is very much appreciated!
来源:https://stackoverflow.com/questions/34821534/pil-tkinter-canvas-eps-to-png-conversion-output-file-contains-issues