# media-preview A picture and PDF pane for Herdr. Open an image or a PDF and it shows beside your terminal, fitted to the pane, with zoom to the point under the cursor, PDF page turning and stepping through the folder. ![media-preview](preview.png) ## What you see - The picture fitted to the pane (never above 1:1), size and scale in the footer: `4096×2560 · 32%`. - PDFs one page at a time, `page 2 / 12 · 63%`. - Arrows in the header to step through pictures in the same folder, with a counter. ## How it behaves - Formats: png, jpg, gif, webp, svg, bmp, heic/heif, tiff, avif, pdf. HEIC, TIFF, AVIF and pictures over 4096 px go through `sips`. SVG stays a vector, so diagrams stay sharp at any zoom. - **Zoom**: ⌘ (or ctrl) + scroll wheel or two-finger scroll, toward the cursor, up to 8× the image pixels. When zoomed, scrolling or dragging pans. Double-click toggles fit ↔ 100% at the clicked point. Keys `+` `-` `0`. - **PDF**: pages rendered by PDFKit through `osascript` (about 0.2 s a page, longest edge up to 3200 px). ← / → or PageUp / PageDown turn pages. A locked PDF shows a message. - **Folder**: ← / → previous / next picture in the same folder. - Reloads by itself when the file changes on disk (an agent re-rendered it). - Drop a picture or PDF from Finder onto the pane to open it. - Commands: `herdr-app do media-preview.open:/path`, `.next`, `.prev`, `.zoom-in`, `.zoom-out`, `.fit`. ## Built from - `mods/media-preview/main.js`: one file, no dependencies. gpui-kit `image()` for the picture, `exec` for `sips` and the PDFKit page render. - Pairs with [md-preview](../md-preview/RECIPE.md): clicked diagrams and pictures there open here. Its `extras/` applet also routes pictures and PDFs to this pane (Open With). ## Install ```sh cp -R mods/media-preview ~/.config/herdr-app/mods/ herdr-app check media-preview # run from ~/.config/herdr-app/mods ``` ## Watch out - macOS-only: `sips` and `osascript` (PDFKit) do the conversions. - Herdr's `image()` reads only files under the app home and does not follow symlinks, so the picture is copied to `mods/media-preview/.cache/` and removed when the pane closes. - No pinch gesture: GPUI gives mods no pinch event, so zoom is ⌘ + scroll. - No video: mods have no video element. The `extras/` script hands videos to QuickTime. ## Done when - `herdr-app do pane.split '{"direction":"right","mod":"media-preview","props":{"file":"/path/photo.heic"}}'` shows the photo fitted, and ⌘ + scroll zooms toward the cursor. - A PDF opens on page 1 and → shows page 2.