Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Commit 6afb0eb

Browse files
authored
Merge pull request #138 from GudlaArunKumar/JpgToPngConvertor
Jpg to png convertor
2 parents b3eb2a4 + 4dee149 commit 6afb0eb

File tree

6 files changed

+41
-0
lines changed

6 files changed

+41
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
'''
2+
Script uses Pillow module to read the image and convert it to png.
3+
sys module for accepting inputs from terminal and os module
4+
for operations on pathnames.
5+
6+
Install Pillow module through "pip install pillow"
7+
'''
8+
9+
import sys,os
10+
from PIL import Image
11+
12+
source_folder = sys.argv[1] # Accepts source folder given in terminal
13+
destination_folder = sys.argv[2] # Accepts destination folder given in terminal
14+
15+
if not os.path.exists(destination_folder): #Check if destination folder exists,if not creates one
16+
os.makedirs(destination_folder)
17+
18+
for filename in os.listdir(source_folder): # For each file present in Source folder
19+
file = os.path.splitext(filename)[0] # Splits file name into as tuple as ('filename','.extension')
20+
img = Image.open(f'{source_folder}/{filename}')
21+
img.save(f'{destination_folder}/{file}.png','png') #Converts to png format
22+
print("Image converted!")
23+
24+
'''
25+
Sample input to run in terminal:
26+
->Python3 JpgToPngConvertor.py Source_Images Destination_Images
27+
28+
Output:
29+
Images in Source_Images folder will be converted into Png Images and gets stored in
30+
Destination_Images folder
31+
'''
32+
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# JPG to PNG Convertor
2+
3+
* This script converts the list of JPG images available in source folder to PNG images
4+
which will get stored in destination folder with help of Pillow module.
5+
6+
* Pillow is a free and open-source additional library for the Python programming language
7+
that adds support for opening, manipulating, and saving many different image file formats.
8+
9+
* Pillow module can be installed using following command "pip install pillow"
Loading
Loading
Loading
Loading

0 commit comments

Comments
 (0)