Last active
January 2, 2022 11:33
-
-
Save conquistadorjd/2c93de1d95fa1a953c2221efc4420c4b to your computer and use it in GitHub Desktop.
image pricessing using PIL, pillow
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| image processing |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################################ | |
| # name: 01_read_image.py | |
| # desc: | |
| # date: 2019-02-10 | |
| # Author: conquistadorjd | |
| ################################################################################################ | |
| from PIL import Image | |
| print('*** Program Started ***') | |
| # image_font_path = 'imagepath_input = '/home/conquistador/code/github/python-01-utilities/image/fonts/' | |
| image_path_input = '/home/conquistador/code/github/python-01-utilities/image/input/' | |
| # image_path_output = '/home/conquistador/code/github/python-01-utilities/image/output/' | |
| image_name_input = '01_read_image.jpg' | |
| im = Image.open(image_path_input + image_name_input) | |
| print('im object: ', im) | |
| print('format : ' , im.format) | |
| print('size : ' , im.size) | |
| print('mode : ' , im.mode) | |
| print('filename : ' , im.filename) | |
| print('width : ' , im.width) | |
| print('height : ' , im.height) | |
| print('info : ' , im.info) | |
| # This will display image on screen | |
| # im.show() | |
| print('*** Program Ended ***') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ################################################################################################ | |
| # name: 02_create_blank_image.py | |
| # desc: Creates blank image files | |
| # date: 2019-02-10 | |
| # Author: conquistadorjd | |
| ################################################################################################ | |
| from PIL import Image, ImageDraw | |
| print('*** Program Started ***') | |
| # image_font_path = 'imagepath_input = '/home/conquistador/code/github/python-01-utilities/image/fonts/' | |
| # image_path_input = '/home/conquistador/code/github/python-01-utilities/image/input/' | |
| image_path_output = '/home/conquistador/code/github/python-01-utilities/image/output/' | |
| image_name_input = '02_create_blank_image_01.jpg' | |
| mode = 'RGB' # for color image “L” (luminance) for greyscale images, “RGB” for true color images, and “CMYK” for pre-press images. | |
| size = (640, 480) | |
| color = (73, 109, 137) | |
| im = Image.new(mode, size, color) | |
| im.save(image_path_output + image_name_input ) | |
| im.show() | |
| print('*** Program Ended ***') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment