Skip to content

Commit bcd76c0

Browse files
committed
Update pillow example to remove redundant copy
1 parent a1a3deb commit bcd76c0

2 files changed

Lines changed: 2 additions & 5 deletions

File tree

‎image-gen/src/entry.py‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
from urllib.parse import parse_qs, urlparse
55

66
from PIL import Image, ImageDraw, ImageFont
7-
from pyodide.ffi import to_js
87
from workers import Request, Response, WorkerEntrypoint
98

109

@@ -321,10 +320,8 @@ def image_to_response(self, image: Image.Image, content_type: str) -> Response:
321320
image_bytes = buffer.getvalue()
322321

323322
# Create and return response with appropriate headers
324-
#
325-
# TODO: This currently performs an unnecessary copy, need to fix.
326323
return Response(
327-
to_js(image_bytes).buffer,
324+
image_bytes,
328325
headers={
329326
"Content-Type": content_type,
330327
"Cache-Control": "public, max-age=3600",

‎image-gen/wrangler.jsonc‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"$schema": "node_modules/wrangler/config-schema.json",
33
"name": "python-image-gen",
44
"main": "src/entry.py",
5-
"compatibility_date": "2025-11-02",
5+
"compatibility_date": "2026-09-08",
66
"compatibility_flags": [
77
"python_workers"
88
],

0 commit comments

Comments
 (0)