Add Image Redraw example combining multiple Cloudflare bindings - #93
Open
ryanking13 wants to merge 5 commits into
Open
Add Image Redraw example combining multiple Cloudflare bindings#93ryanking13 wants to merge 5 commits into
ryanking13 wants to merge 5 commits into
Conversation
for more information, see https://pre-commit.ci
| try { | ||
| rawUpload = await inspectFile(file); | ||
| previewUrl = URL.createObjectURL(rawUpload.file); | ||
| previewImage.src = previewUrl; |
dom96
approved these changes
Aug 21, 2026
|
|
||
| @app.post("/api/jobs", status_code=202) | ||
| async def create_job(request: Request) -> dict[str, str]: | ||
| content_type = request.headers.get("content-type", "").split(";")[0].strip().lower() |
Contributor
There was a problem hiding this comment.
any package we can use that would parse this for us in a more robust way?
| ) | ||
|
|
||
| try: | ||
| await env.REDRAW_QUEUE.send({"jobId": job_id}) |
Contributor
There was a problem hiding this comment.
Instead of submitting this to a queue manually, I wonder if you could use R2's event notifications to show it off and streamline this code https://developers.cloudflare.com/r2/buckets/event-notifications/
| ) | ||
|
|
||
| # Magic bytes, because the model tells us nothing about the format it picked. | ||
| IMAGE_SIGNATURES = ((b"\x89PNG", "image/png"), (b"\xff\xd8\xff", "image/jpeg")) |
Contributor
There was a problem hiding this comment.
That's fun. Are there other formats it could generate? Webp?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds an Image Redraw example similar to something we showed in PyCon US this year.