[Bug]: 'Copy image' on a thread image re-encodes it and strips PNG metadata (tEXt/iTXt); file copy/attach keeps it #41041
Before submitting#
- I searched existing issues and did not find a duplicate.
- I included enough detail to reproduce or investigate the problem.
Area#
apps/desktop
Steps to reproduce#
- Get a PNG that carries ancillary text chunks into a thread, so it shows as an image thumbnail. For example, use a
tEXtchunk with keywordtestand valueMETADATA-SURVIVED, plus aniTXtchunk. - Open the thumbnail and choose right-click → Copy image.
- Paste into the composer with Ctrl+V and send.
- Inspect the saved attachment under
~/.t3/userdata/attachments/, for example withstrings file.png | grep SURVIVEDor by listing the PNG chunks. - For comparison, copy the same PNG file in a file manager (such as Dolphin) and paste it, or attach it with the file picker.
Expected behavior#
Copy image on an image in T3 copies the original image bytes. Pasting it back then stores the same file, ancillary chunks (tEXt/iTXt/zTXt) included, as when the file is copied from a file manager or attached.
Actual behavior#
- After Copy image in T3: the pasted attachment is re-encoded. It has only
IHDR,IDAT,IDATandIEND, everytEXt/iTXtchunk is dropped, and the size changes (581 bytes → 522 bytes). The decoded pixels are bit-identical. - File copied from Dolphin, or attached with the file picker: stored byte-identical, with the metadata intact.
- Placed on the clipboard with
wl-copy --type image/png: the bytes round-trip with an identical hash.
So the loss happens in T3's Copy image action. It probably copies the decoded bitmap, Chromium's default copy-image behaviour, rather than the original file bytes. Writing the original image/png bytes, or the file itself, to the clipboard would fix it.
Impact#
Minor bug or occasional failure
Version or commit#
t3 v0.1.10-nightly.20261116.4800
Environment#
Linux (CachyOS, kernel 7.x), Wayland session, T3 Code desktop app, Claude provider
Workaround#
Copy the PNG file from a file manager, or attach it with the file picker, instead of using Copy image in T3.
Why it matters#
Tools can embed machine-readable context in PNG text chunks so that an agent receiving a pasted screenshot knows exactly where it came from. One example is a note-editor "lasso" screenshot carrying note IDs and a project reference. Copying an image out of a thread and pasting it back is a natural way to pass such screenshots around, but the re-encode silently removes that context.
tanstack-source added labelsbug
juliusmarminge added labelsneeds more info
Yes, the hashes match. The clipboard keeps the original bytes:
$ sha256sum test.png a31a71bf0dfd0f17… test.png $ wl-copy --type image/png < test.png $ wl-paste --list-types image/png $ wl-paste --type image/png | sha256sum # checked after 1 s, 4 s and 20 s a31a71bf0dfd0f17… -Klipper is running, as part of plasmashell 6.8.3 on KDE Plasma (Wayland). It only advertises
image/pngand doesn't replace the contents: the hash stayed identical for at least 20 s.So the original bytes,
tEXt/iTXtchunks included, are still on the clipboard when T3 reads it. The stored attachment was still re-encoded (581 → 522 bytes, ancillary chunks gone, pixels identical).juliusmarminge removed labelsneeds more info
Correction: my original steps were wrong. The paste path is fine. The metadata is lost when the image is copied out of T3. Here is the exact sequence:
- The PNG (with
tEXt/iTXtchunks) appeared in the thread as an image thumbnail. - I opened the thumbnail and chose right-click → Copy image.
- I pasted that into the composer. The stored attachment was re-encoded: 581 → 522 bytes, ancillary chunks gone, pixels identical.
Comparisons:
- Copying the same PNG file in a file manager (Dolphin) and pasting it into the composer keeps it byte-identical, metadata included.
- Attaching the file with the file picker also keeps it byte-identical.
wl-copy --type image/png < test.pnground-trips with an identical hash, as in my previous comment.
So Copy image in T3's image viewer appears to put a re-encoded bitmap on the clipboard (Chromium's default copy-image behaviour) rather than the original file bytes. A fix would be to copy the original
image/pngbytes, or the file itself, for attachments. I'll update the title and steps to match.- The PNG (with
raiscan(GitHub profile, opens in a new tab) changed the title
Confirmed: pasting the raw
image/pngclipboard (put there withwl-copy) into the composer stores the attachment byte-identical: same SHA-256,tEXt/iTXtintact. The paste path is fine. The metadata is only lost when the clipboard came from T3's Copy image on a thread image.Source dive (at 7e3a9ba1). Both paths in
apps/desktop/src/window/ContextMenuImage.ts, called from the Copy Image item inDesktopWindow.ts, re-encode the image:- Main frame (line 13):
contents.copyImageAt(params.x, params.y)puts Chromium's decoded bitmap on the clipboard, and that's written back out as a fresh PNG. Thread thumbnails take this path, so ancillary chunks are lost. - Sub-frames (lines 67–95): this path already fetches the original bytes, but then runs
nativeImage.createFromBuffer(bytes).toPNG()(or a canvasconvertToBlobfallback), which re-encodes them. Only the decoded pixels survive.
Suggested fix: once the bytes are fetched, if they're already a PNG (8-byte signature check), write them unchanged:
const isPng = bytes.subarray(0, 8).equals(Buffer.from([0x89,0x50,0x4e,0x47,0x0d,0x0a,0x1a,0x0a])); const png = isPng ? bytes : image.isEmpty() ? /* existing canvas fallback */ : image.toPNG();Then route main-frame images through the same fetch-and-pass-through path, using
params.srcURL(the attachment/asset URL), instead ofcopyImageAt. KeepcopyImageAtonly as a fallback for sources that can't be fetched. The existing size and dimension checks still apply, because the dimensions come from the header.- Main frame (line 13):
Sign in to join this conversation.
@raiscan After
wl-copy --type image/png < test.png, doeswl-paste --type image/png | sha256summatchsha256sum test.png, and is a clipboard manager such as Klipper running? If the hashes differ, the clipboard contents are being replaced before T3 reads them.