diff --git a/public/image_process.py b/public/image_process.py index a6858cc..cf7e06b 100644 --- a/public/image_process.py +++ b/public/image_process.py @@ -2,22 +2,10 @@ import io import os -from js import Uint8Array, imageUploadList, previewJobQueue +from js import Uint8Array, previewJobQueue from PIL import Image -async def upload_single_image_and_save_to_list( - origin_image, file_name, original_img_path_list -): - array_buf = Uint8Array.new(await origin_image.arrayBuffer()) - bytes_list = bytearray(array_buf) - origin_bytes = io.BytesIO(bytes_list) - my_image = Image.open(origin_bytes) - filePath = f"./{file_name}.png" - original_img_path_list.append(filePath) - my_image.save(filePath) - - async def upload_single_image(origin_image, file_name): array_buf = Uint8Array.new(await origin_image.arrayBuffer()) bytes_list = bytearray(array_buf) @@ -41,18 +29,6 @@ async def upload_file(): return original_img_path -async def upload_files(): - original_img_path_list = [] - for fileItem in imageUploadList: - basename, ext = os.path.splitext(fileItem.name) - if ext.lower() not in [".psd", ".jpg", ".jpeg", ".png"]: - return - await upload_single_image_and_save_to_list( - fileItem, basename, original_img_path_list - ) - return original_img_path_list - - def save_image(image): print("image", image) path = image[0] @@ -65,19 +41,3 @@ def save_image(image): dataurl = f"data:image/{ext};base64,{base64_utf8_str}" print(basename) return [f"img{basename}", dataurl] - - -def save_images(imageList): - returnList = [] - for image in imageList: - path = image[0] - my_image = Image.open(path) - my_stream = io.BytesIO() - my_image.save(my_stream, format="PNG") - binary_fc = open(path, "rb").read() - base64_utf8_str = base64.b64encode(binary_fc).decode("utf-8") - basename, ext = os.path.splitext(path) - dataurl = f"data:image/{ext};base64,{base64_utf8_str}" - print(basename) - returnList.append([f"img{basename}", dataurl]) - return returnList diff --git a/public/scripts/mockup_worker.js b/public/scripts/mockup_worker.js index 4922121..8c17e6c 100644 --- a/public/scripts/mockup_worker.js +++ b/public/scripts/mockup_worker.js @@ -52,7 +52,6 @@ async function main() { self.onmessage = async (event) => { pyodideObject = await pyodideObject; - self["imageUploadList"] = undefined; self["previewJobQueue"].push(event.data.imageUpload); self["locationKey"] = event.data.location; self["deviceId"] = event.data.deviceId;