-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathconvert_jfif_to_png.py
More file actions
36 lines (27 loc) · 850 Bytes
/
convert_jfif_to_png.py
File metadata and controls
36 lines (27 loc) · 850 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# -*- coding: utf-8 -*-
"""
Created on Fri Oct 15 10:10:17 2021
@author: Ibrah
"""
import os
from glob import glob
import cv2
# Constant
INPUT_DIR = "your_input_directory"
def main():
"""Main : loop through a folder then proceeds to convert JFIFF files to PNG files """
# Get the file list
files = glob(INPUT_DIR + "*.jfif")
print(f"Files count: {len(files)}")
# Loop through the files list
for file in files:
# Get the basename (filename)
file_name = os.path.basename(file)
print(f"Image: {file_name}")
image = cv2.imread(file)
# Convert and save the image
cv2.imwrite(INPUT_DIR + "/"+ file_name[0:-5]+".png", image)
# Remove the old file
os.remove(file)
if __name__ == "__main__":
main()