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] Saving a png imaging with PIL

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

  1. Stack

    Stack Membro Participativo

    I am rather new to python and have a problem with the save function of the of PIL when I want run the following code

    #!/usr/bin/env python
    import ImageFont
    import Image
    import ImageDraw
    from PIL import Image
    img=Image.new("RGB", (200,200),(120,20,20))
    draw = ImageDraw.Draw(img)
    draw.text((0, 0),"This is a test",(255,255,0))
    draw = ImageDraw.Draw(img)
    img.save("test.png")


    I have this error I don't know why

    Traceback (most recent call last):
    File "./ima2.py", line 9, in <module>
    draw.text((0, 0),"This is a test",(255,255,0))
    File "/usr/lib64/python2.7/site-packages/PIL/ImageDraw.py", line 260, in text
    font = self.getfont()
    File "/usr/lib64/python2.7/site-packages/PIL/ImageDraw.py", line 133, in getfont
    self.font = ImageFont.load_default()
    File "/usr/lib64/python2.7/site-packages/PIL/ImageFont.py", line 377, in load_default
    '''))))
    File "/usr/lib64/python2.7/site-packages/PIL/ImageFont.py", line 117, in _load_pilfont_data
    image.load()
    File "/usr/lib64/python2.7/site-packages/PIL/ImageFile.py", line 192, in load
    d = Image._getdecoder(self.mode, d, a, self.decoderconfig)
    File "/usr/lib64/python2.7/site-packages/PIL/Image.py", line 381, in _getdecoder
    raise IOError("decoder %s not available" % decoder_name)
    IOError: decoder zip not available

    Continue reading...

Compartilhe esta Página