Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Photos: Copy puts a photo on the clipboard, as a PNG
Yashwanth Kamireddi17ebd5c1d5c6
diff --git a/.uiverify/photos-copy.mjs b/.uiverify/photos-copy.mjsnew file mode 100644index 0000000..c4b8279--- /dev/null+++ b/.uiverify/photos-copy.mjs@@ -0,0 +1,112 @@+// Copy, as in Photos: Ctrl+C on the selected photo, or on the photo open in the viewer, and+// "Copy" in a photo's menu, put it on the clipboard — the app makes the PNG (stubbed here) — and+// say "Copied" quietly. A video offers no Copy and Ctrl+C on one does nothing; several chosen+// copy the first photo of them and say so; a copy that takes a moment says "Copying photo" until+// it is done; one that fails says why. Where the app hands the PNG back (Windows, macOS) the+// window puts it on the clipboard itself: checked in Chromium, whose clipboard can be read back.+//+// URL=http://localhost:4173 node .uiverify/photos-copy.mjs (ENGINE=webkit for WebKit)+import { engine, engineName } from "./engine.mjs";+import { SERVICES, installStub, openScreen } from "./stub.mjs";++const URL = process.env.URL ?? process.env.BASE ?? "http://localhost:4173";+const b = await engine.launch();+let failures = 0;+const ok = (p, m) => { console.log(`${p ? "PASS" : "FAIL"} ${m}`); if (!p) failures++; };++const ctx = await b.newContext({ viewport: { width: 1280, height: 800 } });+await ctx.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });+const page = await ctx.newPage();+page.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+await page.goto(URL, { waitUntil: "networkidle" });+await openScreen(page, "Photos");+await page.locator('.px-tile[data-id="p3"]').waitFor();++const copies = () => page.evaluate(() => window.__copies ?? []);+const toastText = () => page.locator(".toast-host").innerText().catch(() => "");+const waitCopies = (n) => page.waitForFunction((n) => (window.__copies ?? []).length >= n, n);+const waitToast = (re) => page.waitForFunction((src) => new RegExp(src).test(document.querySelector(".toast-host")?.innerText ?? ""), re.source);+const clearToasts = () => page.evaluate(() => document.querySelectorAll(".toast-close").forEach((b) => b.click()));++// Ctrl+C on one selected photo.+await page.locator('.px-tile[data-id="p2"]').click();+await page.keyboard.press("Control+c");+await waitCopies(1);+await waitToast(/Copied/);+ok(JSON.stringify(await copies()) === '["p2"]', `Ctrl+C copies the selected photo (${JSON.stringify(await copies())})`);+ok(/^\s*Copied\s*$/m.test(await toastText()), `…and says "Copied" (${JSON.stringify(await toastText())})`);+await clearToasts();++// A photo's menu offers Copy; a video's does not, and Ctrl+C on a video copies nothing.+await page.locator('.px-tile[data-id="p4"]').click({ button: "right" });+ok((await page.locator(".row-menu").getByText("Copy", { exact: true }).count()) === 1, "a photo's menu offers Copy");+await page.locator(".row-menu").getByText("Copy", { exact: true }).click();+await waitCopies(2);+ok((await copies()).at(-1) === "p4", "Copy in the menu copies that photo");+await clearToasts();+await page.locator('.px-tile[data-id="p3"]').click({ button: "right" });+ok((await page.locator(".row-menu").getByText("Copy", { exact: true }).count()) === 0, "a video's menu offers no Copy");+await page.keyboard.press("Escape");+await page.locator('.px-tile[data-id="p3"]').click();+await page.keyboard.press("Control+c");+await page.waitForTimeout(250);+ok((await copies()).length === 2, `Ctrl+C on a video copies nothing (${(await copies()).length} copies)`);++// Several chosen, a video first: the first photo of them, and it says so.+await page.locator('.px-tile[data-id="p5"]').click({ modifiers: ["Control"] });+await page.locator('.px-tile[data-id="p1"]').click({ modifiers: ["Control"] });+await page.keyboard.press("Control+c");+await waitCopies(3);+await waitToast(/Copied the first photo/);+ok((await copies()).at(-1) === "p1", `several chosen copy the first photo of them, passing the video (${(await copies()).at(-1)})`);+await clearToasts();++// In the viewer: Ctrl+C copies the photo shown.+await page.keyboard.press("Escape");+await page.locator('.px-tile[data-id="p5"]').dblclick();+await page.locator(".px-viewer").waitFor();+await page.keyboard.press("Control+c");+await waitCopies(4);+ok((await copies()).at(-1) === "p5", "Ctrl+C in the viewer copies the photo shown");+await page.locator(".px-stage").click({ button: "right", position: { x: 300, y: 300 } });+ok((await page.locator(".row-menu").getByText("Copy", { exact: true }).count()) === 1, "the open photo's own menu offers Copy");+await page.keyboard.press("Escape");+await clearToasts();++// A slow copy says so while it is made; a quick one never does.+await page.evaluate(() => { window.__copyDelay = 900; });+await page.keyboard.press("Control+c");+await waitToast(/Copying photo/);+ok(true, "a copy that takes a moment says \"Copying photo\"");+await waitToast(/^\s*Copied\s*$/m);+ok(!/Copying photo/.test(await toastText()), `…which goes once it is copied (${JSON.stringify(await toastText())})`);+await clearToasts();+await page.evaluate(() => { window.__copyDelay = 0; window.__copyFail = true; });+await page.keyboard.press("Control+c");+await waitToast(/clipboard didn’t take/);+ok(true, "a copy that fails says why");+await page.evaluate(() => { window.__copyFail = false; });+await clearToasts();+await page.keyboard.press("Escape");+await ctx.close();++// Windows and macOS: the PNG comes back and the window puts it on the clipboard.+if (engineName === "chromium") {+ const c2 = await b.newContext({ viewport: { width: 1280, height: 800 }, permissions: ["clipboard-read", "clipboard-write"] });+ await c2.addInitScript(installStub, { screen: "library", services: SERVICES, twoFactor: null });+ // A 1×1 PNG.+ await c2.addInitScript(() => { window.__copyPng = "iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8DwHwAFBQIAX8jx0gAAAABJRU5ErkJggg=="; });+ const p2 = await c2.newPage();+ p2.on("pageerror", (e) => ok(false, `page error: ${e.message}`));+ await p2.goto(URL, { waitUntil: "networkidle" });+ await openScreen(p2, "Photos");+ await p2.locator('.px-tile[data-id="p2"]').click();+ await p2.keyboard.press("Control+c");+ await p2.waitForFunction(() => /Copied/.test(document.querySelector(".toast-host")?.innerText ?? ""));+ const types = await p2.evaluate(async () => (await navigator.clipboard.read()).flatMap((i) => i.types));+ ok(types.includes("image/png"), `where the PNG comes back, it is on the clipboard as image/png (${types.join(", ")})`);+ await c2.close();+}++await b.close();+process.exitCode = failures ? 1 : 0;diff --git a/.uiverify/stub.mjs b/.uiverify/stub.mjsindex 43de881..2c8739d 100644--- a/.uiverify/stub.mjs+++ b/.uiverify/stub.mjs@@ -821,6 +821,14 @@ export function installStub({ screen, services, twoFactor, calendarFixture, notecase "window_tint": (window.__tints ??= []).push(args.rgb.join(",")); return null;case "window_fullscreen": (window.__fullscreen ??= []).push(args.on); return args.on;case "photo_download": (window.__downloads ??= []).push(args); return `/home/test/Downloads/IMG_${args.id}.JPG`;+ // Linux's answer (the app put it on the clipboard: nothing back) unless a test hands the+ // PNG back as Windows and macOS do (__copyPng), after __copyDelay ms when one is set.+ case "photo_copy": {+ (window.__copies ??= []).push(args.id);+ if (window.__copyDelay) await new Promise((r) => setTimeout(r, window.__copyDelay));+ if (window.__copyFail) throw "The clipboard didn’t take the photo.";+ return window.__copyPng ? Uint8Array.from(atob(window.__copyPng), (c) => c.charCodeAt(0)).buffer : new ArrayBuffer(0);+ }// Each file is answered at once with where it stands; a test plays the rest in with __emit.case "photos_upload": {(window.__photoUploads ??= []).push(args.paths);diff --git a/crates/quince-media/fixtures/two.heic b/crates/quince-media/fixtures/two.heicnew file mode 100644index 0000000..ca9e44dBinary files /dev/null and b/crates/quince-media/fixtures/two.heic differdiff --git a/crates/quince-media/src/lib.rs b/crates/quince-media/src/lib.rsindex c5698bb..62312e8 100644--- a/crates/quince-media/src/lib.rs+++ b/crates/quince-media/src/lib.rs@@ -99,17 +99,23 @@ fn cut(image: image::DynamicImage, crop: Option<Crop>) -> image::DynamicImage {////// # Errors/// When the bytes are not a HEIF image libheif can decode.+pub fn heic_to_jpeg(bytes: &[u8]) -> Result<Vec<u8>, String> {+ let picture = heic_rgb(bytes)?;+ let mut out = std::io::Cursor::new(Vec::new());+ image::codecs::jpeg::JpegEncoder::new_with_quality(&mut out, 92)+ .encode_image(&picture)+ .map_err(|e| e.to_string())?;+ Ok(out.into_inner())+}+#[cfg(all(windows, target_env = "gnu"))]-pub fn heic_to_jpeg(_bytes: &[u8]) -> Result<Vec<u8>, String> {+fn heic_rgb(_bytes: &[u8]) -> Result<image::RgbImage, String> {Err("HEIC pictures are not decoded in this build.".into())}-/// A HEIC picture made a JPEG (see the variant above for the one build where it is not).-///-/// # Errors-/// When the bytes are not a HEIF image libheif can decode.+/// A HEIC picture's pixels, upright (see the variant above for the one build where it is not).#[cfg(not(all(windows, target_env = "gnu")))]-pub fn heic_to_jpeg(bytes: &[u8]) -> Result<Vec<u8>, String> {+fn heic_rgb(bytes: &[u8]) -> Result<image::RgbImage, String> {use libheif_rs::{ColorSpace, HeifContext, LibHeif, RgbChroma};let lib = LibHeif::new();let ctx = HeifContext::read_from_bytes(bytes).map_err(|e| e.to_string())?;@@ -127,12 +133,45 @@ pub fn heic_to_jpeg(bytes: &[u8]) -> Result<Vec<u8>, String> {for y in 0..h as usize {rgb.extend_from_slice(&plane.data[y * stride..y * stride + row]);}- let picture = image::RgbImage::from_raw(w, h, rgb).ok_or("the picture had the wrong size")?;- let mut out = std::io::Cursor::new(Vec::new());- image::codecs::jpeg::JpegEncoder::new_with_quality(&mut out, 92)- .encode_image(&picture)+ image::RgbImage::from_raw(w, h, rgb).ok_or_else(|| "the picture had the wrong size".to_string())+}++/// A photo as a PNG, upright: what Copy puts on the clipboard. PNG because it is lossless and+/// is the picture type every desktop's apps take from the clipboard; HEIC never goes there —+/// most apps cannot read it. A HEIC is decoded here (libheif turns it as the file says);+/// anything else is turned the way its camera wrote it, since a PNG carries no orientation of+/// its own. Fast compression: a 12-megapixel photo is ready in well under a second, and the+/// bytes are only held while they are on the clipboard.+///+/// # Errors+/// When the bytes are not a picture this can decode.+pub fn to_png(bytes: &[u8]) -> Result<Vec<u8>, String> {+ use image::codecs::png::{CompressionType, FilterType, PngEncoder};+ use image::ImageDecoder;+ let picture = if is_heif(bytes) {+ image::DynamicImage::ImageRgb8(heic_rgb(bytes)?)+ } else {+ let mut decoder = image::ImageReader::new(std::io::Cursor::new(bytes))+ .with_guessed_format()+ .map_err(|e| e.to_string())?+ .into_decoder()+ .map_err(|e| e.to_string())?;+ let orientation = decoder+ .orientation()+ .unwrap_or(image::metadata::Orientation::NoTransforms);+ let mut picture = image::DynamicImage::from_decoder(decoder).map_err(|e| e.to_string())?;+ picture.apply_orientation(orientation);+ picture+ };+ let mut out = Vec::new();+ picture+ .write_with_encoder(PngEncoder::new_with_quality(+ &mut out,+ CompressionType::Fast,+ FilterType::Adaptive,+ )).map_err(|e| e.to_string())?;- Ok(out.into_inner())+ Ok(out)}/// RGB rows (`stride` bytes apart) made a JPEG, as heic_to_jpeg makes one.@@ -676,6 +715,60 @@ mod tests {assert!(super::fit(jpg.get_ref(), 800).unwrap().is_none());}+ /// Copy's picture from a HEIC: a PNG, whole and in its colours (red left, blue right — a+ /// 64×32 HEIC made with libheif's own heif-enc).+ #[cfg(not(all(windows, target_env = "gnu")))]+ #[test]+ fn a_heic_is_copied_as_a_png() {+ let heic = include_bytes!("../fixtures/two.heic");+ assert!(super::is_heif(heic));+ let png = super::to_png(heic).unwrap();+ assert_eq!(&png[..8], b"\x89PNG\r\n\x1a\n");+ let back = image::load_from_memory_with_format(&png, image::ImageFormat::Png)+ .unwrap()+ .to_rgb8();+ assert_eq!(back.dimensions(), (64, 32));+ let (left, right) = (back.get_pixel(8, 16).0, back.get_pixel(56, 16).0);+ assert!(left[0] > 200 && left[2] < 60, "{left:?}");+ assert!(right[2] > 200 && right[0] < 60, "{right:?}");+ }++ /// A JPEG the camera wrote on its side comes out upright: a PNG has no orientation to say+ /// it with, so the turn is made in the pixels.+ #[test]+ fn a_jpeg_is_copied_upright() {+ let img = image::RgbImage::from_fn(40, 20, |x, _| {+ if x < 20 {+ image::Rgb([255, 0, 0])+ } else {+ image::Rgb([0, 0, 255])+ }+ });+ let mut jpg = Vec::new();+ image::DynamicImage::ImageRgb8(img)+ .write_to(+ &mut std::io::Cursor::new(&mut jpg),+ image::ImageFormat::Jpeg,+ )+ .unwrap();+ // An EXIF block saying "turn a quarter clockwise" (orientation 6), put after SOI.+ let exif: &[u8] =+ b"Exif\0\0MM\0\x2a\0\0\0\x08\0\x01\x01\x12\0\x03\0\0\0\x01\0\x06\0\0\0\0\0\0";+ let len = u16::try_from(exif.len() + 2).unwrap().to_be_bytes();+ let mut turned = jpg[..2].to_vec();+ turned.extend_from_slice(&[0xFF, 0xE1, len[0], len[1]]);+ turned.extend_from_slice(exif);+ turned.extend_from_slice(&jpg[2..]);+ let back = image::load_from_memory(&super::to_png(&turned).unwrap())+ .unwrap()+ .to_rgb8();+ assert_eq!(back.dimensions(), (20, 40));+ // Turned clockwise, the red left half is now the top.+ let top = back.get_pixel(10, 5).0;+ assert!(top[0] > 200 && top[2] < 60, "{top:?}");+ assert!(super::to_png(b"not a picture").is_err());+ }+use super::*;/// A drawing's white goes, its ink stays; in dark, black ink turns white and a mid-tonediff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rsindex 05e43f2..d08293f 100644--- a/src-tauri/src/main.rs+++ b/src-tauri/src/main.rs@@ -6676,6 +6676,7 @@ fn main() {photos::photo_set_date,photos::photos_search,photos::photo_download,+ photos::photo_copy,note_table_add_row,note_table_remove,note_attachment_info,diff --git a/src-tauri/src/photos.rs b/src-tauri/src/photos.rsindex 40da57b..b6bd34d 100644--- a/src-tauri/src/photos.rs+++ b/src-tauri/src/photos.rs@@ -2050,6 +2050,89 @@ pub async fn photos_counts(app: AppHandle, data: State<'_, Data>) -> UiResult<Ve.map_err(|e| e.to_string())}+/// A photo put on the clipboard as a PNG, as Photos' Copy puts one, to paste into any app with+/// nothing saved first. Made from the best picture already on this computer — the original when+/// it is here (a HEIC decoded, never put there as HEIC), else the whole picture kept for the+/// viewer — and fetched only when neither is. Read-only: nothing is asked of iCloud but the+/// picture itself. Decoded and made a PNG off the window's thread.+///+/// On Linux it is offered on the clipboard here, through GTK — the window's own toolkit, which+/// speaks Wayland's clipboard and X11's alike — and nothing comes back. Elsewhere the PNG comes+/// back for the window to put there (the webview's own clipboard, which on Windows and macOS+/// takes a PNG as the system's picture type).+#[tauri::command]+pub async fn photo_copy(+ id: String,+ app: AppHandle,+ data: State<'_, Data>,+) -> UiResult<tauri::ipc::Response> {+ let photo = data+ .0+ .lock()+ .await+ .photo(&id)+ .map_err(|e| e.to_string())?+ .ok_or("That photo is no longer in the library.")?;+ if photo.kind == quince_core::photos::Kind::Video {+ return Err("A video can’t be copied as a picture.".into());+ }+ let (original, full) = (+ cache_path(&app, &id, Size::Original),+ cache_path(&app, &id, Size::Full),+ );+ let png_of = |path: PathBuf| async move {+ crate::photo_cache::hold(&path);+ let bytes = tokio::fs::read(&path).await.map_err(|e| e.to_string())?;+ crate::cpu::run(move || quince_media::to_png(&bytes)).await?+ };+ if tokio::fs::metadata(&full).await.is_err() && tokio::fs::metadata(&original).await.is_err() {+ // Neither here yet: the whole picture, as the viewer would fetch it (a HEIC's comes with+ // its original, which is then the one used).+ cached(&app, &id, Size::Full).await?;+ }+ // The original first; one this cannot decode (a RAW) gives way to the whole picture.+ let from_original = if tokio::fs::metadata(&original).await.is_ok() {+ png_of(original).await+ } else {+ Err(String::new())+ };+ let png = match from_original {+ Ok(png) => png,+ Err(_) => png_of(cached(&app, &id, Size::Full).await?).await?,+ };+ #[cfg(target_os = "linux")]+ {+ offer_png(&app, png).await?;+ Ok(tauri::ipc::Response::new(Vec::new()))+ }+ #[cfg(not(target_os = "linux"))]+ Ok(tauri::ipc::Response::new(png))+}++/// A PNG offered on the desktop's clipboard through GTK, on the thread GTK lives on. Held by+/// the clipboard until something else is copied; a clipboard manager keeps it past that.+#[cfg(target_os = "linux")]+async fn offer_png(app: &AppHandle, png: Vec<u8>) -> Result<(), String> {+ let (tx, rx) = tokio::sync::oneshot::channel();+ app.run_on_main_thread(move || {+ let clipboard = gtk::Clipboard::get(&gdk::SELECTION_CLIPBOARD);+ let targets = [gtk::TargetEntry::new(+ "image/png",+ gtk::TargetFlags::empty(),+ 0,+ )];+ let offered = clipboard.set_with_data(&targets, move |_, selection, _| {+ selection.set(&gdk::Atom::intern("image/png"), 8, &png);+ });+ let _ = tx.send(offered);+ })+ .map_err(|e| e.to_string())?;+ match rx.await {+ Ok(true) => Ok(()),+ _ => Err("The clipboard didn’t take the photo.".into()),+ }+}+/// A photo saved to Downloads, as icloud.com's Download Options choose the file: the original/// as captured, the highest quality (edits included), or the most compatible (JPEG or MP4). Both/// records are read fresh — their links expire — and the file is streamed to a part file, nameddiff --git a/src/lib/ipc.ts b/src/lib/ipc.tsindex e13f71e..2717ea5 100644--- a/src/lib/ipc.ts+++ b/src/lib/ipc.ts@@ -234,6 +234,9 @@ export const api = {* the most compatible. Answers where it was saved. */photoDownload: (id: string, want?: "originals" | "highestQuality" | "mostCompatible") =>invoke<string>("photo_download", { id, want: want ?? null }),+ /** A photo on the clipboard as a PNG. On Linux it is put there by the app and nothing comes+ * back; elsewhere the PNG comes back for the window to put there. */+ photoCopy: (id: string) => invoke<ArrayBuffer>("photo_copy", { id }),/** Title and caption together, as Info saves them. */photoSetText: (id: string, title: string, caption: string) => invoke<Photo>("photo_set_text", { id, title, caption }),photoSetRating: (id: string, rating: number) => invoke<Photo>("photo_set_rating", { id, rating }),diff --git a/src/screens/PhotosView.tsx b/src/screens/PhotosView.tsxindex e4cbc8a..627c6a6 100644--- a/src/screens/PhotosView.tsx+++ b/src/screens/PhotosView.tsx@@ -28,7 +28,7 @@ import { Arriving, EmptyState } from "../components/EmptyState";import { SearchField } from "../components/SearchField";import { PaneTitle } from "../components/PaneTitle";import { useArriving, useRevision } from "../lib/sync";-import { toast, toastSaved, useErrorToast, useToastClearance } from "../components/Toast";+import { dismissToast, toast, toastSaved, useErrorToast, useToastClearance } from "../components/Toast";import { UploadPanel } from "./photos/UploadPanel";import { RowMenu, type MenuEntry } from "../components/RowMenu";import { Portal } from "../components/Portal";@@ -1577,6 +1577,8 @@ export function PhotosView() {else if (e.key === "Escape") close();// Cmd/Ctrl + "." closes too, as icloud.com's one-up view does.else if ((e.ctrlKey || e.metaKey) && e.key === ".") close();+ // Ctrl+C: the photo shown, on the clipboard — unless words in the Info are selected.+ else if ((e.ctrlKey || e.metaKey) && !e.shiftKey && !e.altKey && e.key.toLowerCase() === "c" && current && current.kind !== "video" && !window.getSelection()?.toString()) void copy([current.id]);// Z: fit, or the photo at full size about its middle.else if (e.key.toLowerCase() === "z" && !e.ctrlKey && !e.metaKey && current?.kind !== "video") {const box = pan.current?.getBoundingClientRect();@@ -1937,6 +1939,9 @@ export function PhotosView() {if (!selectAll && !t?.closest?.(".px") && t !== document.body) return;if (ctrl && e.key.toLowerCase() === "a") {setChosen(new Set(list));+ } else if (ctrl && !e.shiftKey && !e.altKey && e.key.toLowerCase() === "c" && selected.length && place !== "recentlyDeleted") {+ // Ctrl+C: the selected photo on the clipboard, to paste into any app.+ void copy(selected);} else if (e.key === "Escape" && chosen.size) {setChosen(new Set());} else if ((e.key === "Enter" || e.key === " ") && t?.closest?.(".px-tile[data-index]") && !t.closest(".px-tile")!.matches('[aria-selected="true"]')) {@@ -2159,6 +2164,8 @@ export function PhotosView() {]: [{ label: p.favorite ? "Unfavorite" : "Favorite", run: () => void change(p, "favorite", !p.favorite) },+ // A picture to paste anywhere; a video has none to give.+ ...(p.kind !== "video" ? [{ label: "Copy", run: () => void copy([p.id]) }] : []),{ label: "Download", run: () => void download(p) },{ label: "More Download Options", run: () => setOptions([p]) },{ label: "Start Slideshow", run: () => startShow(p) },@@ -2362,6 +2369,41 @@ export function PhotosView() {}};+ /**+ * Copy, as in Photos: the photo on the clipboard as a picture, to paste into any app. One+ * picture — the clipboard holds one, on Linux and Windows alike — so with several chosen it+ * is the first photo of them (a video is never copied). Quiet: "Copied" once it is there, and+ * a word while it is made only when that takes a moment (a large HEIC, or one not here yet).+ */+ const copying = useRef(0);+ const copy = async (ids: string[]) => {+ const mine = ++copying.current;+ let picked: Photo | undefined;+ try {+ picked = (await store.load(ids)).find((x) => x.kind !== "video");+ } catch (e) {+ setError(messageOf(e));+ return;+ }+ if (!picked) return;+ let waitNote = 0;+ const slow = window.setTimeout(() => {+ waitNote = toast({ message: "Copying photo", duration: null });+ }, 300);+ try {+ const png = await api.photoCopy(picked.id);+ // Not on Linux, where the app has put it there itself: the webview's own clipboard, which+ // takes a PNG as the system's picture.+ if (png.byteLength) await navigator.clipboard.write([new ClipboardItem({ "image/png": new Blob([png], { type: "image/png" }) })]);+ if (mine === copying.current) toast({ message: ids.length > 1 ? "Copied the first photo" : "Copied", tone: "done" });+ } catch (e) {+ if (mine === copying.current) setError(messageOf(e));+ } finally {+ window.clearTimeout(slow);+ if (waitNote) dismissToast(waitNote);+ }+ };+const download = async (p: Photo) => {try {const where = await api.photoDownload(p.id);