Closed PeaceDealer closed 3 years ago
Can you show us a picture of what you get?
Like this
How interesting. It looks like it's maybe drawing 5 concentric ellipses and then aliasing is happening on the parts which aren't straight?
Do you get a solid line if you specify width = 1?
Its a continues line, however not very circular. There are places where it seems a little jittery, which could seem to line up with the white spots at width 5.
I guess this may be an issue with the PIL library then.
I was just trying to generate an RGB image, where its not an issue, but I cant get the display to process that directly.
Testing this in pure PIL on my desktop yields a solid - if someone ropey - line as you might expect:
Code:
from PIL import Image, ImageDraw, __version__
print(__version__)
image = Image.new("P", (300, 300), 0)
draw = ImageDraw.Draw(image)
draw.ellipse((20, 20, 280, 280), fill=None, outline=1, width=5)
image.putpalette([255, 255, 255, 0, 0, 0])
image = image.resize((600, 600), Image.NEAREST)
image.show()
Assuming there wasn't some weird version of PIL where circles weren't rendered solid, I'm guessing set_image
is failing to detect the image as "P" (palette) type and trying to quantize it.
But in the interest of science, what does the above code do for you?
Edit: This is the code path you should not be hitting: https://github.com/pimoroni/inky/blob/75f12b415ad1ae42ac3be92b33f83f51519f5da3/library/inky/inky_uc8159.py#L381-L391
This is the exact code i ran on the raspberry pi:
from PIL import Image, ImageDraw, __version__
print(__version__)
image = Image.new("P", (300, 300), 0)
draw = ImageDraw.Draw(image)
draw.ellipse((20, 20, 280, 280), fill=None, outline=1, width=5)
image.putpalette([255, 255, 255, 0, 0, 0])
image = image.resize((600, 600), Image.NEAREST)
image.save("test.png")
and the image that it generates looks like this:
So it seems the PIL libary for some reason is to blame. It returns as version 5.4.1
on the pi.
Same on my Inky pHAT with PIL 5.4.1.
Well since PIL is intent on being.... weird... (even my circles leave much to be desired) ... perhaps this will work better:
from PIL import Image, ImageDraw, __version__
print(__version__)
image = Image.new("P", (300, 300), 0)
draw = ImageDraw.Draw(image)
width = 5
draw.ellipse((20, 20, 280, 280), fill=1, outline=None)
draw.ellipse((20 + width, 20 + width, 280 - width, 280 - width), fill=0, outline=None)
image.putpalette([255, 255, 255, 0, 0, 0])
image = image.resize((600, 600), Image.NEAREST)
image.show()
I was on the stock inky library install using the bash script from the product page.
I just:
sudo apt remove python3-pil
sudo pip3 install -Iv pillow==6.2.2
(latest version that supports Python 2.7)
sudo apt install libopenjp2-7
and now:
Looks good! (Well, as good as a badly rasterised circle with no antialiasing will ever look)
Can confirm, after changing to the pillow Libary everything works fine.
I'm using the inky wHAT, and I'm trying to draw an analog clock face, however, the outline of the PIL Ellipse tool doesn't seem to be solid. Got lots of white dots sprinkled around the outline.
This is the code which I'm using