Best Way To Draw Pixel In Python
I was wondering, what is the simplest way to draw a pixel in python with x and y values?
Solution 1:
Probably the simplest way is use PIL (Python Imaging Library) which makes it possible in 4 lines:
from PIL import Image, ImageColor
im = Image.new('1', (1,1)) # create the Image of size 1 pixel
im.putpixel((0,0), ImageColor.getcolor('black', '1')) # or whatever color you wish
im.save('simplePixel.png') # or any image format
The documentation shows lots of other ways to customize it http://pillow.readthedocs.io/en/3.4.x/reference/Image.html#examples.
Post a Comment for "Best Way To Draw Pixel In Python"