mirror of
https://seed.radicle.dev/rad:z4D5UCArafTzTQpDZNQRuqswh3ury.git
synced 2026-11-16 08:30:43 +08:00
Show Retina screenshots at their intended size
macOS saves Retina screenshots at 144 DPI and we rendered them at twice the size they had on screen. We now scale PNGs with a 2x or 3x density down; everything else, including 300 DPI print exports, stays 1:1.
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
import { toDom } from "hast-util-to-dom";
|
||||
import { mount, tick, unmount } from "svelte";
|
||||
|
||||
import { embedPreviewKind } from "@app/lib/embeds";
|
||||
import { embedPreviewKind, retinaWidth } from "@app/lib/embeds";
|
||||
import { parseFrontmatter } from "@app/lib/frontmatter";
|
||||
import { invoke } from "@app/lib/invoke";
|
||||
import {
|
||||
@@ -73,10 +73,15 @@
|
||||
function createEmbedPreview(
|
||||
mimeType: string | null,
|
||||
url: string,
|
||||
content: Uint8Array,
|
||||
): HTMLElement | undefined {
|
||||
const kind = embedPreviewKind(mimeType);
|
||||
if (kind === "image") {
|
||||
const element = document.createElement("img");
|
||||
const width = retinaWidth(content);
|
||||
if (width) {
|
||||
element.style.width = `${width}px`;
|
||||
}
|
||||
element.setAttribute("src", url);
|
||||
element.style.display = "block";
|
||||
return element;
|
||||
@@ -308,10 +313,9 @@
|
||||
}
|
||||
let preview = embedPreviews.get(href);
|
||||
if (!preview) {
|
||||
const url = URL.createObjectURL(
|
||||
new Blob([Buffer.from(content)]),
|
||||
);
|
||||
const element = createEmbedPreview(mimeType, url);
|
||||
const bytes = Buffer.from(content);
|
||||
const url = URL.createObjectURL(new Blob([bytes]));
|
||||
const element = createEmbedPreview(mimeType, url, bytes);
|
||||
if (!element) {
|
||||
URL.revokeObjectURL(url);
|
||||
console.warn(
|
||||
|
||||
Reference in New Issue
Block a user