Skip to content

Added png to jpg convertor #701

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions png_to_jpg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# PNG to JPG converter
A simple python script to convert png image to jpg image
## Modules Used

- pillow
- os

## Requirements

- Run the following in the directory containing the script files.

```bash
pip install requests pillow
```
- Place the PNG file in **input** folder
- Then run the below command

```bash
python main.py
```

- Converted JPG file will be available in **output** folder
Binary file added png_to_jpg/input/mario.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions png_to_jpg/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from PIL import Image
import os

project_root_path = os.path.dirname(os.path.abspath(__file__))

# open image in png format
img_png = Image.open(project_root_path + '/input/mario.png')

# converting image to RGB
rgb_im = img_png.convert('RGB')

# The image object is used to save the image in jpg format
rgb_im.save(project_root_path + '/output/mario.jpg')
1 change: 1 addition & 0 deletions png_to_jpg/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pillow