Skip to content

Add Bun image transformation docs#7961

Open
sorenbs wants to merge 3 commits into
mainfrom
codex/image-transformations-compute
Open

Add Bun image transformation docs#7961
sorenbs wants to merge 3 commits into
mainfrom
codex/image-transformations-compute

Conversation

@sorenbs

@sorenbs sorenbs commented Jun 18, 2026

Copy link
Copy Markdown
Member

Summary by CodeRabbit

  • Documentation
    • Added a new “Image Transformations” guide for Prisma Compute, including a minimal /images/* example, caching headers and negotiation guidance, source-handling best practices, and a security checklist.
    • Published a companion blog post with deeper implementation and caching patterns for request-time image transforms using Bun.
    • Updated the Compute docs landing page and page index to include the new Image Transformations resource.

@vercel

vercel Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
blog Ready Ready Preview, Comment Jun 18, 2026 8:09am
docs Ready Ready Preview, Comment Jun 18, 2026 8:09am
eclipse Ready Ready Preview, Comment Jun 18, 2026 8:09am
site Ready Ready Preview, Comment Jun 18, 2026 8:09am

Request Review

@github-actions

github-actions Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

🍈 Lychee Link Check Report

21 links: ✅ 1 OK | 🚫 0 errors | 🔀 1 redirects | 👻 19 excluded

✅ All links are working!


Full Statistics Table
Status Count
✅ Successful 1
🔀 Redirected 1
👻 Excluded 19
🚫 Errors 0
⛔ Unsupported 0
⏳ Timeouts 0
❓ Unknown 0

@coderabbitai

coderabbitai Bot commented Jun 18, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • apps/blog/public/image-transformations-with-bun-on-prisma-compute/imgs/hero.svg is excluded by !**/*.svg

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 7696dd8d-fb93-47f7-a4ef-46d5849de882

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

Adds a new Prisma Compute docs page (apps/docs) and a blog post (apps/blog) covering image transformation using Bun's native Bun.Image API. The docs page includes a full Hono route example, source handling patterns, transformation options, caching guidance, Vercel/Cloudflare migration tables, and a security checklist. The blog post covers the same topic in article form with additional narrative, caching optimization patterns, and operational guidance. Navigation entries in meta.json and index.mdx register the new docs page in the sidebar.

Changes

Compute Docs: Image Transformations

Layer / File(s) Summary
Navigation wiring
apps/docs/content/docs/compute/meta.json, apps/docs/content/docs/compute/index.mdx
Inserts "image-transformations" into the sidebar pages array and adds a cross-link from the Compute index's "What to read next" list.
Docs page: intro, Bun.Image overview, and minimal route example
apps/docs/content/docs/compute/image-transformations.mdx
Frontmatter, introduction to Bun.Image primitives, and a complete Hono route example covering path validation, query parsing, resizing, format encoding, and cache/Vary response headers, followed by deployment instructions and example request URLs.
Docs page: source handling, transformation options, and caching
apps/docs/content/docs/compute/image-transformations.mdx
Covers remote fetch and S3-compatible source patterns, all transformation options (resize fit modes, rotate/flip, modulation, format encoders, placeholders, content negotiation), and caching strategy with immutable headers.
Docs page: Vercel/Cloudflare migration maps, advanced libraries, security, and next links
apps/docs/content/docs/compute/image-transformations.mdx
Maps Vercel Image Optimization and Cloudflare Images parameters to Prisma Compute equivalents, provides guidance for integrating advanced image libraries with a consistent route shape, adds a security checklist, and closes with "What to read next" links.

Blog Post: Image Transformations with Bun on Prisma Compute

Layer / File(s) Summary
Blog post: frontmatter, introduction, and minimal Hono route
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx
MDX frontmatter with metadata/hero image, introductory narrative framing vendor services, description of image optimization as app logic, and a full Hono route with allowlisting, parameter capping, resizing, format selection, and cache headers, plus deployment examples and route summary.
Blog post: HTTP cache headers, conditional requests, and filesystem cache optimization
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx
Expands cache header semantics (immutable max-age, Vary: Accept) with ETag-based conditional request example, then adds a local per-instance filesystem caching layer with hash-based keys, async read/write helpers, budget enforcement, and best-effort pruning; clarifies ephemeral nature and suggests object storage for durable cross-instance caching.
Blog post: advanced patterns, Bun vs. platform comparison, and feature mapping
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx
Documents non-request-time Bun.Image usage (variant generation, placeholders, avatar transformations), then provides a feature-comparison table mapping Cloudflare and Vercel platform behaviors to Bun-native capabilities or route-level logic, noting missing crop/advanced vision/portable format features.
Blog post: billing model and operational conclusion
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx
Explains that transformations are treated as regular application work with costs attributed to request/CPU/memory/bandwidth rather than transformation units, then provides Prisma Compute onboarding guidance (auth login, deployment, logging) and links to official docs and Discord.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the main change: adding documentation for Bun image transformations on Prisma Compute.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@argos-ci

argos-ci Bot commented Jun 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Argos notifications ↗︎

Build Status Details Updated (UTC)
default (Inspect) ✅ No changes detected - Jun 18, 2026, 8:15 AM

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/docs/content/docs/compute/image-transformations.mdx`:
- Line 23: The spell checker (cspell) is flagging the legitimate technical terms
`lanczos3` and `EXIF` as spelling errors in the documentation. Instead of
modifying the documentation prose, add these terms to the cspell dictionary
whitelist configuration file (typically cspell.json or similar configuration at
the project root). This will allow the spell checker to recognize these
technical terms as valid and pass CI without altering the documentation content.
Ensure both `lanczos3` and `EXIF` are added to the words list since they appear
across multiple lines in the document (lines 23, 80, and 355).
- Around line 141-147: The Cache-Control header in the Response constructor
includes the "immutable" directive, but since the source asset is fetched by
name only (products/chair.jpg) without version or hash, the upstream asset can
change in place and users will remain stuck on stale versions. Remove the
"immutable" directive from the Cache-Control header and either add
versioning/hash to the source URL path or replace it with a shorter max-age TTL
combined with ETag-based cache revalidation strategy to handle source updates
properly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5bad8cc6-70b8-46bf-bee4-40359aa157cb

📥 Commits

Reviewing files that changed from the base of the PR and between bdbd8c6 and 6c99b6c.

⛔ Files ignored due to path filters (1)
  • apps/blog/public/image-transformations-with-bun-on-prisma-compute/imgs/hero.svg is excluded by !**/*.svg
📒 Files selected for processing (4)
  • apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx
  • apps/docs/content/docs/compute/image-transformations.mdx
  • apps/docs/content/docs/compute/index.mdx
  • apps/docs/content/docs/compute/meta.json

| Resize by width or width and height | `resize(width)` or `resize(width, height)` |
| Preserve aspect ratio inside a box | `resize(width, height, { fit: "inside" })` |
| Prevent upscaling | `resize(width, height, { withoutEnlargement: true })` |
| Choose resize filter | `filter: "lanczos3"`, `"mitchell"`, `"box"`, `"nearest"`, and others |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Whitelist the technical spellcheck terms.

lanczos3 and EXIF are legitimate technical terms, but cspell is already failing on them in CI. Please add them to the docs dictionary instead of changing the prose.

Also applies to: 80-80, 355-355

🧰 Tools
🪛 GitHub Actions: Spellcheck / 0_Validate documentation spelling.txt

[error] 23-23: cspell (lint:spellcheck) reported an unknown word: 'lanczos' (context: resize filter; suggesting 'lanczos3'/'mitchell').

🪛 GitHub Actions: Spellcheck / Validate documentation spelling

[error] 23-23: cspell: Unknown word (lanczos) at 23:36. Context: filter: "lanczos3", "mitchell", ...

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/docs/content/docs/compute/image-transformations.mdx` at line 23, The
spell checker (cspell) is flagging the legitimate technical terms `lanczos3` and
`EXIF` as spelling errors in the documentation. Instead of modifying the
documentation prose, add these terms to the cspell dictionary whitelist
configuration file (typically cspell.json or similar configuration at the
project root). This will allow the spell checker to recognize these technical
terms as valid and pass CI without altering the documentation content. Ensure
both `lanczos3` and `EXIF` are added to the words list since they appear across
multiple lines in the document (lines 23, 80, and 355).

Source: Pipeline failures

Comment on lines +141 to +147
return new Response(body, {
headers: {
"Cache-Control": "public, max-age=31536000, immutable",
"Content-Type": body.type,
"Vary": "Accept",
},
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't mark mutable source URLs as immutable.

This example fetches products/chair.jpg by name only, so Cache-Control: immutable can leave users stuck on stale variants if the upstream asset changes in place. Either version the source path/hash or switch this sample to a shorter TTL/ETag strategy.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/docs/content/docs/compute/image-transformations.mdx` around lines 141 -
147, The Cache-Control header in the Response constructor includes the
"immutable" directive, but since the source asset is fetched by name only
(products/chair.jpg) without version or hash, the upstream asset can change in
place and users will remain stuck on stale versions. Remove the "immutable"
directive from the Cache-Control header and either add versioning/hash to the
source URL path or replace it with a shorter max-age TTL combined with
ETag-based cache revalidation strategy to handle source updates properly.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx (1)

254-273: ⚡ Quick win

Integration snippet may cause copy-paste confusion due to incomplete variable scope.

The code snippet at lines 254–273 shows how to wire the filesystem cache into your route, but it references width, height, quality, fit, and format variables that aren't defined in this partial view. A developer copying this snippet directly will get undefined reference errors. The variables are defined in the outer full route example (lines 98–139), but the connection isn't explicit.

Consider either:

  • Adding a comment in the snippet explicitly stating "These variables come from the parameter parsing section above" and referencing line numbers, or
  • Showing the full route context so it's clear these are from the parameter-parsing section.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`
around lines 254 - 273, The code snippet in the route handler references
undefined variables (width, height, quality, fit, and format) that are not
defined within this partial view. These variables are defined in the
parameter-parsing section earlier in the full route example. Add a clear comment
at the beginning of this code snippet stating that these variables come from the
parameter-parsing section above, or restructure the documentation to show the
complete route context by including the parameter-parsing code before this
cache-integration snippet so the variable definitions and their usage are
together in one continuous example.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`:
- Around line 237-239: The pathFor function uses Bun.hash(key) without a seed
argument, which generates random process-specific hashes that differ across
process restarts, breaking cache consistency. Fix this by adding a fixed seed
value as the second argument to Bun.hash() in the pathFor function, changing
Bun.hash(key) to Bun.hash(key, 0) to ensure the same input always produces the
same hash output regardless of when or where the process runs.

---

Nitpick comments:
In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`:
- Around line 254-273: The code snippet in the route handler references
undefined variables (width, height, quality, fit, and format) that are not
defined within this partial view. These variables are defined in the
parameter-parsing section earlier in the full route example. Add a clear comment
at the beginning of this code snippet stating that these variables come from the
parameter-parsing section above, or restructure the documentation to show the
complete route context by including the parameter-parsing code before this
cache-integration snippet so the variable definitions and their usage are
together in one continuous example.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 963cc44f-8249-4e4f-bf24-72153266aa45

📥 Commits

Reviewing files that changed from the base of the PR and between 6c99b6c and c31cdb8.

📒 Files selected for processing (1)
  • apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx

Comment on lines +237 to +239
function pathFor(key: string) {
return `${CACHE_DIR}/${Bun.hash(key).toString(16)}`;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

Does Bun.hash() produce deterministic output across process restarts and what seed does it use?

💡 Result:

Bun.hash does not produce deterministic output across process restarts by default because it uses a random seed when none is provided [1][2]. To ensure deterministic output that remains consistent across process restarts or different environments, you must explicitly provide a seed as the second argument to the function [1][2]. Regarding the seed: - Default behavior: When the seed argument is omitted, Bun uses a random, process-specific seed [1]. This means that calling Bun.hash('data') will return different results each time the process is restarted [1]. - Deterministic usage: You can achieve consistent output by passing a fixed numeric value (number or bigint) as the seed [1][3]. For example, Bun.hash('data', 0) will consistently produce the same output every time [1]. It is also important to note that Bun.hash is a non-cryptographic hash function based on algorithms like Wyhash [4][3]. While providing a seed makes the hash deterministic for a specific input across restarts, users have reported that the underlying hash implementation can sometimes yield different results for the same input across different operating systems or platforms (e.g., Windows vs. Linux) [5]. If cross-platform or environment-independent stability is required, it is recommended to test your specific use case or consider alternative hashing solutions [5].

Citations:


Fix the non-deterministic hash function that breaks the cache across process restarts.

The cache key generation uses Bun.hash(key).toString(16) without a seed argument. By default, Bun.hash() uses a random, process-specific seed, meaning the same input produces different hashes after each restart. This makes the filesystem cache ineffective across warm instances or redeploys—each new process generates new cache keys and misses all prior cached data.

To fix this, provide a fixed seed as the second argument: Bun.hash(key, 0).toString(16). This ensures consistent cache keys across all instances and deployments. If you need cryptographic guarantees, consider SHA256 instead, though for cache keys the determinism is the critical requirement here.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/blog/content/blog/image-transformations-with-bun-on-prisma-compute/index.mdx`
around lines 237 - 239, The pathFor function uses Bun.hash(key) without a seed
argument, which generates random process-specific hashes that differ across
process restarts, breaking cache consistency. Fix this by adding a fixed seed
value as the second argument to Bun.hash() in the pathFor function, changing
Bun.hash(key) to Bun.hash(key, 0) to ensure the same input always produces the
same hash output regardless of when or where the process runs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant