Skip to content

Commit

Permalink
Remove unuse scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
YayunHuang committed Aug 28, 2024
1 parent af1e33d commit 9958292
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 42 deletions.
42 changes: 1 addition & 41 deletions public/image_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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]
Expand All @@ -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
1 change: 0 additions & 1 deletion public/scripts/mockup_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 9958292

Please sign in to comment.