···158158async function postDrawing(env, did, rkey, cid) {
159159 const [author, bot] = await Promise.all([miniDoc(did), miniDoc(BOT_HANDLE)]);
160160161161- // post the white-backed PNG (the worker flattens the transparent drawing onto
162162- // white), not the raw blob — otherwise the transparency shows the dark
161161+ // post the white-backed image (the worker flattens the transparent drawing
162162+ // onto white), not the raw blob — otherwise the transparency shows the dark
163163 // background in Bluesky's dark mode. fall back to the raw blob if /img fails.
164164- let imgRes = await fetch(
165165- `${APP}/img/${did}/${cid}?w=1024&bg=ffffff&fmt=png`,
166166- { headers: { accept: "image/png" } },
167167- );
168168- if (!imgRes.ok) {
164164+ // upload with the ACTUAL returned content-type (the flattener may emit jpeg).
165165+ let imgRes = await fetch(`${APP}/img/${did}/${cid}?w=1024&bg=ffffff&fmt=png`, {
166166+ headers: { accept: "image/png" },
167167+ });
168168+ let mime = "image/png";
169169+ if (imgRes.ok) {
170170+ mime = imgRes.headers.get("content-type") || "image/png";
171171+ } else {
169172 imgRes = await fetch(`${author.pds}/xrpc/com.atproto.sync.getBlob?did=${did}&cid=${cid}`);
170173 }
171174 if (!imgRes.ok) throw new Error(`image fetch ${imgRes.status}`);
···181184 bot.pds,
182185 "com.atproto.repo.uploadBlob",
183186 bytes,
184184- "image/png",
187187+ mime,
185188 auth,
186189 );
187190 const detail = `${APP}/l/${did}/${rkey}`;