Skip to content

Commit fd18c07

Browse files
authored
Merge pull request #701 from Kapileson/main
Added png to jpg convertor
2 parents 58b34d7 + 9980377 commit fd18c07

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

png_to_jpg/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# PNG to JPG converter
2+
A simple python script to convert png image to jpg image
3+
## Modules Used
4+
5+
- pillow
6+
- os
7+
8+
## Requirements
9+
10+
- Run the following in the directory containing the script files.
11+
12+
```bash
13+
pip install requests pillow
14+
```
15+
- Place the PNG file in **input** folder
16+
- Then run the below command
17+
18+
```bash
19+
python main.py
20+
```
21+
22+
- Converted JPG file will be available in **output** folder

png_to_jpg/input/mario.png

584 KB
Loading

png_to_jpg/main.py

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from PIL import Image
2+
import os
3+
4+
project_root_path = os.path.dirname(os.path.abspath(__file__))
5+
6+
# open image in png format
7+
img_png = Image.open(project_root_path + '/input/mario.png')
8+
9+
# converting image to RGB
10+
rgb_im = img_png.convert('RGB')
11+
12+
# The image object is used to save the image in jpg format
13+
rgb_im.save(project_root_path + '/output/mario.jpg')

png_to_jpg/requirements.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pillow

0 commit comments

Comments
 (0)