File tree 4 files changed +36
-0
lines changed
4 files changed +36
-0
lines changed Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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' )
Original file line number Diff line number Diff line change
1
+ pillow
You can’t perform that action at this time.
0 commit comments