Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Python create a new png file

from pil import Image

def newImg():
    img = Image.new('RGB', (100, 100))
    img.putpixel((30, 60), (155, 155, 55))
    img.save(r'C:UserslenovoDesktopsqr.png')

    return img

newImg()
Comment

python how to make a png

import png
s = ['110010010011',
     '101011010100',
     '110010110101',
     '100010010011']
s = [[int(c) for c in row] for row in s]

w = png.Writer(len(s[0]), len(s), greyscale=True, bitdepth=1)
f = open('png.png', 'wb')
w.write(f, s)
f.close()

# https://pypng.readthedocs.io/en/latest/ex.html
Comment

PREVIOUS NEXT
Code Example
Python :: how to generate random number in python 
Python :: pandas access multiindex column 
Python :: save imag epillow 
Python :: django bulk update 
Python :: continue python 
Python :: how to remove an element from a list in python 
Python :: python mann kendall test 
Python :: pandas df by row index 
Python :: python programm zu exe 
Python :: python get first occurrence in list 
Python :: permission denied when converting dataframe to csv 
Python :: python string interpolation 
Python :: how to find and remove certain characters from text string in python 
Python :: pandas value in series 
Python :: sphinx autodoc command 
Python :: tensorflow.keras.utils.to_categorical 
Python :: make gif from images in python 
Python :: append a dataframe to an empty dataframe 
Python :: jupyter notebook cell background color 
Python :: access to specific column array numpy 
Python :: python while loop break 
Python :: pandas fillna with none 
Python :: super title python 
Python :: python get class from string 
Python :: while True: 
Python :: docstrings in python 
Python :: how to get more than one longest string in a list python 
Python :: python syntax errors 
Python :: argparse flag without value 
Python :: how to set the size of a kivy window bigger than screen 
ADD CONTENT
Topic
Content
Source link
Name
4+5 =