diff --git a/png_to_jpg/README.md b/png_to_jpg/README.md new file mode 100644 index 000000000..741f0ddc0 --- /dev/null +++ b/png_to_jpg/README.md @@ -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 diff --git a/png_to_jpg/input/mario.png b/png_to_jpg/input/mario.png new file mode 100644 index 000000000..f2b60f783 Binary files /dev/null and b/png_to_jpg/input/mario.png differ diff --git a/png_to_jpg/main.py b/png_to_jpg/main.py new file mode 100644 index 000000000..1060f235a --- /dev/null +++ b/png_to_jpg/main.py @@ -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') diff --git a/png_to_jpg/requirements.txt b/png_to_jpg/requirements.txt new file mode 100644 index 000000000..3868fb16b --- /dev/null +++ b/png_to_jpg/requirements.txt @@ -0,0 +1 @@ +pillow