mirror of
https://github.com/abdulkader-safi/obsidian-image-magick-plugins.git
synced 2026-07-22 08:27:44 +00:00
The wasm engine was 6.9 MB of the plugin's 7 MB, over Obsidian's limit.
safi-image does the same work in pure TypeScript, taking main.js to 843 KB.
The engine's exported surface is unchanged, so the editor and every panel
are untouched: same UI, same pipeline order, same preset behaviour.
Two things the port has to solve rather than inherit:
- safi-image's PNG codec calls node:zlib, which Obsidian mobile does not
have. src/zlib-shim.ts maps it onto fflate, and an esbuild plugin
resolves it at build time. fflate's deflateSync is raw DEFLATE where
node's is zlib-wrapped, so the shim uses zlibSync/unzlibSync and a test
pins that against node's own zlib; the wrong pair writes PNGs nothing
can open. fflate exports no crc32, so the table is here too.
- previews paint through a canvas instead of encoding a PNG per frame.
A pure-TypeScript DEFLATE on the UI thread is exactly the stutter the
preview architecture exists to avoid.
AVIF and HEIC go with ImageMagick: both are patent-encumbered and no pure
TypeScript decoder for them exists. They are dropped from the format list,
the openable extensions, and preset validation, so neither can be picked
and fail at save time.
|
||
|---|---|---|
| .. | ||
| node-shims.mjs | ||