Spaces:
Running
Running
Dan Biagini
commited on
Commit
•
e02b873
1
Parent(s):
0200926
add zip files module
Browse files- src/zip_files.py +11 -0
src/zip_files.py
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import zipfile
|
2 |
+
import io
|
3 |
+
from PIL import Image
|
4 |
+
|
5 |
+
def extract_files_from_zip(zip_path):
|
6 |
+
file_objects = {}
|
7 |
+
with zipfile.ZipFile(zip_path, 'r') as zip_ref:
|
8 |
+
for file_name in zip_ref.namelist():
|
9 |
+
with zip_ref.open(file_name) as file:
|
10 |
+
file_objects[file_name] = Image.open(io.BytesIO(file.read()))
|
11 |
+
return file_objects
|