Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 418a056

Browse files
Merge pull request avinashkranjan#228 from vaishnavijha/master
Added text on image script
2 parents 7497c9e + 52f24ff commit 418a056

File tree

3 files changed

+32
-0
lines changed

3 files changed

+32
-0
lines changed

‎Text_on_image.py/readme.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Pillow (Python Imaging Library (PIL))
2+
Pillow is a Python Imaging Library (PIL), which adds support for opening, manipulating, and saving images.Pillow is built on top of PIL (Python Image Library). PIL is one of the important modules for image processing in Python.Pillow module gives more functionalities, runs on all major operating system and support for python 3. It supports wide variety of images such as "jpeg", "png", "bmp", "gif", "ppm", "tiff". You can do almost anything on digital images using pillow module. Apart from basic image processing functionality, including point operations, filtering images using built-in convolution kernels, and color space conversions.
3+
4+
5+
## Setup instructions
6+
7+
install pillow in your system by running pip install pillow in terminal or command prompt and the setup is ready.To add text, you must first download a 'font' file locally to your machine, for example for Times Roman [times-ro.ttf] (https://www.download-free-fonts.com/details/86847/ times-roman) Then you can add text in times new roman.
8+
9+
10+
## Output
11+
12+
the ouput is in capture.png image attached in this folder.
13+
link to collab file:
14+
https://colab.research.google.com/drive/1N-3d7AthbpvcGmdWSG6Pl_HhkzN2ldo1?authuser=3#scrollTo=FZkDaQnbOIDt
15+
16+
## Author(s)
17+
18+
vaishnavi jha

‎Text_on_image.py/text_on_image.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#run pip install pillow on terminal
2+
from PIL import Image #importing required libraries
3+
from PIL import ImageFont
4+
from PIL import ImageDraw
5+
6+
img = Image.new('RGB', (600, 400), color = 'red')#here we are creating an image which is a simple rectangle of 600*400 dimension but instead we can also have an image
7+
img.save('pil_red.png')#if we want to add text on the image we have already we do not need to write these two lines of code
8+
font = ImageFont.truetype("times-ro.ttf", 24)#we have downloaded times new roman font from internet as described in readme file
9+
img = Image.new('RGB', (600, 400), color = 'red')
10+
11+
draw = ImageDraw.Draw(img)
12+
draw.text((300, 200),"Hello world !",(0,0,0),font=font)#we can choose our font accordingly and the text on the image
13+
14+
img.save('pil.png')#a new image is saved ,which has text on image .
87.5 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /