Skip to content

Latest commit

 

History

History
50 lines (29 loc) · 1.62 KB

Python_Convert_PNG_Images_To_JPG.md

File metadata and controls

50 lines (29 loc) · 1.62 KB



Template request | Bug report | Generate Data Product

Tags: #jpg #png #to #image #images #convert

Author: Ahmed Mousa

Description: This notebook converts png images to jpg images.

Input

Import libraries

from PIL import Image

Setup Variables

Make sure you put your file absolute path or put the file within this notebook directory.

file_path = "Put your file path here / Make sure it's withing this notebook dire"

Model

Open image and converts to RGB colors

img_png = Image.open(file_path)
img_png = img_png.convert("RGB")

Replacing file name extensions

new_file_path = file_path.replace("png", "jpg")

Output

Save result as jpg file

img_png.save(new_file_path)