1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Anuncie Aqui
    Anuncie aqui você Também: fdantas@4each.com.br

[Python] why is the bg colour of the saved turtle fig. not black(as per the colour stated) ?...

Discussão em 'Python' iniciado por Stack, Setembro 14, 2025.

  1. Stack

    Stack Membro Participativo

    from PIL import Image, EpsImagePlugin
    import os
    import turtle

    EpsImagePlugin.gs_windows_binary=r'C:\\Program Files\\gs\\gs10.01.2\bin\\gswin64c'

    point=turtle.Turtle(); point.speed(0); point.color('yellow')
    point.penup(); point.sety(- 6*25); point.pendown()

    point.begin_fill()
    point.circle(6*25, steps=6)
    point.end_fill()

    point.hideturtle()

    screen=turtle.Screen(); screen.bgcolor('black')[turtle image](https://i.sstatic.net/1t5V0.png)
    board=screen.getcanvas(); board.postscript(file="test_drawing.eps")

    Image.open("test_drawing.eps").save("test_drawing.jpg", "JPEG")
    Image.open(r'C:\\Users\\parth\Desktop\\coding\\test_drawing.jpg').show()[saved image](https://i.sstatic.net/asQUQ.png)
    Image.open(r'C:\\Users\\parth\Desktop\\coding\\test_drawing.jpg').rotate(45, fillcolor='black', expand=True).show()[the output i want but with a complete black bg](https://i.sstatic.net/cYpF6.png)

    os.remove(path=r'C:\\Users\\parth\Desktop\\coding\\test_drawing.jpg')


    how can i fix this code so that the saved fig has a black bg instead of the default black one ?

    hope someone can help me fix this block of code.

    Continue reading...

Compartilhe esta Página