Create an image file using PIL (Python Imaging Library).

Runs on Python 2.7. It seems that PIL does not yet support Python 3 series.

What is PIL (Python Imaging Library)?

Python Imaging Library (PIL)

Python Imaging Library - Wikipedia

Image processing library. It seems that various image processing is implemented.

Sample for the time being

image.py


#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Create an image file
"""

import Image

def make_image(screen, bgcolor, filename):
    """
Creating an image
    """
    img = Image.new('RGB', screen,bgcolor)
    #
    #Add various processes here
    #
    img.save(filename)
    return

if __name__ == '__main__':
    #Image size
    screen = (1024,768)

    #Image background color (RGB)
    bgcolor=(0xdd,0xdd,0xdd)

    #File name to save (File format is automatically determined from the extension)
    filename = "pil-01.png "

    make_image(screen, bgcolor, filename)

#EOF

It is a script that just creates an image file (PNG format) without any twist.

Based on this script, we plan to add various image processing.

Recommended Posts

Create an image file using PIL (Python Imaging Library).
[Hyperledger Iroha] Create an account using Python library
Introduction of Python Imaging Library (PIL) using HomeBrew
Create an Excel file with Python3
PIL (Python Imaging Library) installation memorandum
Quickly create an excel file with Python #python
Create a GIF file using Pillow in Python
Create polka dot wallpaper with Python Image Library
Create wav file from GLSL shader using python3
Create an image with characters in python (Japanese)
Create a MIDI file in Python using pretty_midi
Make each PowerPoint page an image file in Python
Create your first GDSII file in Python using gdspy
How to create an image uploader in Bottle (Python)
[Python] Create an infrastructure diagram in 3 minutes using diagrams
Create JIRA tickets using Python
Try to operate an Excel file using Python (Pandas / XlsxWriter) ①
Try to operate an Excel file using Python (Pandas / XlsxWriter) ②
Convert images to sepia toning with PIL (Python Imaging Library)
Paste the image into an excel file using Python's openpyxl
A sample for drawing points with PIL (Python Imaging Library).
[Python] Create an event-driven web crawler using AWS's serverless architecture
[Python Kivy] How to create an exe file with pyinstaller
How to create an ISO file (CD image) on Linux
Cut out an image with python
Image capture of firefox using python
[Python] Using OpenCV with Python (Image Filtering)
Create a python GUI using tkinter
[Python] Using OpenCV with Python (Image transformation)
Create a binary file in Python
Create a simple scheduled batch using Docker's Python Image and parse-crontab
Extract the targz file using python
Create a graph that displays an image with a mouse hover using the data visualization library Dash
[For Python] Quickly create an upload file to AWS Lambda Layer
[Python] File operation using if statement
Easily create homemade RPA using Python
[Python] Create a linebot to write a name and age on an image
Python: Basics of image recognition using CNN
Create an image processing viewer with PySimpleGUI
How to convert Python to an exe file
Python: Application of image recognition using CNN
Install python library on Lambda using [/ tmp]
[Python] Create a Batch environment using AWS-CDK
Use cryptography library cryptography with Docker Python image
Create an application using the Spotify API
Create Excel file with Python + similarity matrix
Create a deb file from a python package
Create an OpenCV3 + python3 environment on OSX
[GPS] Create a kml file in Python
[Python] Quickly create an API with Flask
Create an English word app with python
Create an upgradeable msi file with cx_Freeze
Create an elliptical scatter plot in Python without using a multivariate normal distribution
Get the size of the image file on the web (Python3, no additional library required)
Feel free to turn Python using the library into an AWS Lambda function
[Personal memo] julia --Using Python library with julia using PyCall
Aggregate test results using the QualityForward Python library
[Python] Split a large Flask file using Blueprint
Chord recognition using chromagram of python library librosa
Create an executable file in a scripting language
Create an image composition app with Flask + Pillow