diff --git a/Python/JpgToPngConvertor/JpgToPngConvertor.py b/Python/JpgToPngConvertor/JpgToPngConvertor.py new file mode 100644 index 00000000..b50545ad --- /dev/null +++ b/Python/JpgToPngConvertor/JpgToPngConvertor.py @@ -0,0 +1,48 @@ +''' +Copyright [2020] [Arun Kumar G] +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +''' + +''' +Script uses Pillow module to read the image and convert it to png. +sys module for accepting inputs from terminal and os module +for operations on pathnames. + +Install Pillow module through "pip install pillow" +''' + +import sys,os +from PIL import Image + +source_folder = sys.argv[1] # Accepts source folder given in terminal +destination_folder = sys.argv[2] # Accepts destination folder given in terminal + +if not os.path.exists(destination_folder): #Check if destination folder exists,if not creates one + os.makedirs(destination_folder) + +for filename in os.listdir(source_folder): # For each file present in Source folder + file = os.path.splitext(filename)[0] # Splits file name into as tuple as ('filename','.extension') + img = Image.open(f'{source_folder}/{filename}') + img.save(f'{destination_folder}/{file}.png','png') #Converts to png format + print("Image converted!") + +''' +Sample input to run in terminal: +->Python3 JpgToPngConvertor.py Source_Images Destination_Images + +Output: +Images in Source_Images folder will be converted into Png Images and gets stored in +Destination_Images folder +''' + + + + diff --git a/Python/JpgToPngConvertor/README.md b/Python/JpgToPngConvertor/README.md new file mode 100644 index 00000000..e8c866d6 --- /dev/null +++ b/Python/JpgToPngConvertor/README.md @@ -0,0 +1,9 @@ +# JPG to PNG Convertor + +* This script converts the list of JPG images available in source folder to PNG images +which will get stored in destination folder with help of Pillow module. + +* Pillow is a free and open-source additional library for the Python programming language +that adds support for opening, manipulating, and saving many different image file formats. + +* Pillow module can be installed using following command "pip install pillow" diff --git a/Python/JpgToPngConvertor/Source_Images/bulbasaur.jpg b/Python/JpgToPngConvertor/Source_Images/bulbasaur.jpg new file mode 100644 index 00000000..df7408b3 Binary files /dev/null and b/Python/JpgToPngConvertor/Source_Images/bulbasaur.jpg differ diff --git a/Python/JpgToPngConvertor/Source_Images/charmander.jpg b/Python/JpgToPngConvertor/Source_Images/charmander.jpg new file mode 100644 index 00000000..d902b84c Binary files /dev/null and b/Python/JpgToPngConvertor/Source_Images/charmander.jpg differ diff --git a/Python/JpgToPngConvertor/Source_Images/pikachu.jpg b/Python/JpgToPngConvertor/Source_Images/pikachu.jpg new file mode 100644 index 00000000..420a7c71 Binary files /dev/null and b/Python/JpgToPngConvertor/Source_Images/pikachu.jpg differ diff --git a/Python/JpgToPngConvertor/Source_Images/squirtle.jpg b/Python/JpgToPngConvertor/Source_Images/squirtle.jpg new file mode 100644 index 00000000..96aaa3f8 Binary files /dev/null and b/Python/JpgToPngConvertor/Source_Images/squirtle.jpg differ