Skip to content

Commit 9980377

Browse files
committed
Added png to jpg converter
1 parent 123bf19 commit 9980377

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

png_to_jpg/README.md

Lines changed: 22 additions & 0 deletions
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

Lines changed: 13 additions & 0 deletions
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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
pillow

0 commit comments

Comments
 (0)