Created
October 5, 2018 16:01
-
-
Save Luxato/6986f1edf4c22d371793177219c6facf to your computer and use it in GitHub Desktop.
Convert .png images into .jpg with python3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import xml.etree.ElementTree as ET | |
import pickle | |
import os | |
from os import listdir, getcwd | |
from os.path import join | |
from PIL import Image | |
source_dir = "C:\\Users\\Lukas\\Desktop\\KITTI dataset\\left_camera\\VOC2012\\JPEGImages" | |
directory = os.fsencode(source_dir) | |
i = 0; | |
for file in os.listdir(directory): | |
i = i + 1 | |
filename = os.fsdecode(file) | |
print(i) | |
im = Image.open(source_dir + "\\" + filename) | |
rgb_im = im.convert('RGB') | |
filename = filename[:-4] | |
filename = filename + ".jpg" | |
rgb_im.save('C:\\Users\\Lukas\\Desktop\\jpg_images\\' + filename) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment