← All posts
Fix

spark-ssr 1.3.3 — phone photos no longer upload sideways

spark-ssr 1.3.3 is a one-line fix for a real annoyance: a photo taken on a phone — a profile picture, a captured video poster — could render rotated after upload, even though nothing in your CSS touches it.

Why it happened

Phone cameras almost always save the sensor's native (landscape) pixels plus an EXIF Orientation tag that says "rotate this 90° for display." Viewers honor that tag, so the photo looks upright.

When spark-ssr has the optional spark-html-image pipeline enabled, it converts uploaded png/jpg files to webp at write time. The problem: webp output drops the EXIF tag entirely. So the conversion threw away the one piece of information that said "rotate me," while leaving the raw sideways pixels untouched — and every viewer, having nothing left to correct, showed it rotated.

The fix

Call .rotate() before writing the webp. With no arguments, sharp's .rotate() bakes the EXIF orientation into the actual pixels, so the upright result survives even when the tag is dropped:

// packages/spark-ssr/src/request.js
await sharp(uploaded)
  .rotate()                 // ← bake EXIF orientation into the pixels first
  .webp({ quality: 82 })
  .toFile(out);

It's exactly what the sibling spark-html-image build-time pipeline already did — the upload-time path just never got the same call.

Upgrading

Pure bug fix, no breaking changes, no API surface change:

bun add spark-ssr@^1.3.3

spark-ssr on npm · ssr-v1.3.3 on GitHub.