Repository navigation
Card Editor Dialog
English · Español
"Edit card" is the modal for touching up one card's existing image: rotation, zoom/pan framing and eleven colour/detail adjustments. It applies the result to that card, to its copies, or to all cards, and shows a live preview rendered by the same Rust code as the PDF. It is not the card designer; see Relation to the designer below.

| File | Role |
|---|---|
src/features/card-editor/card-editor-dialog.tsx |
CardEditorDialog (mounted once in src/App.tsx) and its inner Content
|
src/features/card-editor/propagate.ts |
Scope, copiesOf, applyEdits: pure functions deciding which cards get the edit |
src/features/card-editor/__tests__/propagate.test.ts |
Tests for the scope rules |
src/lib/live-image.ts |
useThrottled, useBurst, useLiveImage (real-time image updates, shared with the Designer UI) |
src/lib/image-url.ts |
encodeParams, thumbnailUrl, NEUTRAL_EDITS
|
- Double-click a card slot in the preview (
src/features/preview/slot-view.tsx, only if the card has an image:card?.front). - Context menu "Edit card" (
src/features/preview/slot-menu.tsx; disabled with several cards selected or when the card has no image).
Both call useUi.getState().open({ kind: "edit", id }); CardEditorDialog reads useUi.dialog, looks the card up with cardById(id) (src/features/preview/card-actions.ts) and opens only if card.front exists.
CardEdits (src-tauri/crates/proxy-core/src/model.rs, binding in src/bindings/CardEdits.ts) is stored on each DeckCard.edits:
| Field | Meaning | UI |
|---|---|---|
rotation |
r0, r90, r180, r270 (lossless) |
Two buttons: rotate left/right, shows 0/90/180/270 |
crop |
zoom (>= 1), offsetX, offsetY in [-1, 1] inside the slack the zoom leaves (0 = centred) |
Zoom slider 1x-2x, horizontal/vertical framing sliders, drag on the image when zoom > 1 |
adjust |
Adjustments: the eleven retouches |
Sliders |
The eleven retouches, in the order of the ADJUSTMENTS list (the order of the original web tool this app clones): brightness, exposure, contrast, saturation, warmth, vibrance (all -100..100); sharpness, clarity, noise reduction, vignette, fade (all 0..100). 0 = no effect, NEUTRAL_EDITS is the all-zero value. Rust applies them in a fixed order (noise reduction, exposure, brightness, contrast, warmth, saturation, vibrance, clarity, sharpness, fade, vignette) with radii in millimetres so a 488 px thumbnail and a 600 dpi PDF look the same (src-tauri/crates/proxy-core/src/imaging/adjust.rs).
Framing in Rust (imaging/frame.rs): rotate, then crop box from zoom/offset, then Lanczos3 resample to the exact slot size. The image is stretched to the card shape; only if its aspect ratio is more than 15 % off (MAX_STRETCH) is it cropped to cover. See Imaging and PDF.
flowchart LR
S["sliders / buttons / drag"] --> B["draft: CardEdits (useState)"]
B -->|"useThrottled 60 ms"| P["painted"]
P -->|"useBurst"| W{"burst?"}
W -->|yes| U1["thumbnailUrl 488 px"]
W -->|no| U2["thumbnailUrl 745 px"]
U1 --> V["useLiveImage"]
U2 --> V
V --> I["img (last loaded)"]
B -->|"approximateFilter"| F["CSS filter bridges the gap"]
F --> I
-
draftholds the edits being edited.painted = useThrottled(draft, 60)lets the value through at most every 60 ms (the last one always arrives), so Rust is asked for a new image at slider speed but never flooded. - The image URL is
thumbnailUrl(front.blob, encodeParams(settings, painted, false, 0), width)→pbimg://…/r/<blob>/<base64url params>/<width>(src-tauri/src/protocol.rs).encodeParamspacks the deck'sedgeDarkening, bleed mode, corner fill, card size and the edits intoPreviewParams. Rust renders it withAppState::thumbnail(src-tauri/src/render.rs), the sameimaging::pipeline::renderthe PDF uses, and caches the JPEG atapp_cache_dir/renders/<RenderSpec key>.jpg. -
useBurst(painted)is true while edits change faster than every 250 ms; the request is then 488 px wide, otherwise 745 px. -
useLiveImage(url)keeps the previous image on screen until the new one has loaded (no flicker or blank). - Between a slider move and the new image arriving,
approximateFilter(draft.adjust, onScreen.adjust)applies a CSSbrightness/contrast/saturatefilter computed from the difference between the current draft and the adjustments the displayed image was rendered with. AbyUrlmap (cleared past 64 entries) remembers which edits each requested URL used, soonScreenis exact even if an older image is still shown. Only brightness, exposure, contrast, saturation and vibrance are approximated; rotation, framing, sharpness and the rest simply wait for Rust. - A spinner appears while an image loads (
loading).
onDown only starts a drag when draft.crop.zoom > 1. onMove converts the pointer delta (as a fraction of the frame) to offset deltas scaled by the slack 1 - 1/zoom, clamps both offsets to [-1, 1] and writes them to the draft. The cursor shows grab only when zoom > 1.
For Scryfall cards and tokens (source.kind === "scryfall" | "token"), a zoom above 1.05 shows an amber warning: "With this zoom the card footer (artist and copyright) is cropped". It is a notice only.
| Button | Scope |
Effect (applyEdits) |
|---|---|---|
| "Apply" | card |
Only this card gets the whole edit. Disabled when nothing changed (JSON.stringify(draft) === JSON.stringify(card.edits)). |
"Also apply to its copies (n)" (shown only if n > 0) |
copies |
This card plus every card with the same front image hash (front.blob) gets the whole edit: rotation, framing and retouches, because the image is identical. |
| "Apply to all cards" | all |
This card gets the whole edit; every other card with an image gets only the colour adjustments (adjust) merged into its own edits (their rotation and framing are kept: those depend on each image). |
-
copiesOf(cards, card)= other cards whosefront.blobequals this card's; a card without an image has no copies even if other blank slots exist. - Cards that are not touched keep the same object identity (tests assert it), which keeps React and the history cheap.
- All three go through one
useDeck.getState().setCards(...)call, so one undo step reverts the whole operation (see State Stores). Then an announcement is shown ("Card edited", "Card and its N copies edited" or "Edits applied to all cards") and the dialog closes. - "Reset all" resets the draft to
NEUTRAL_EDITS(disabled when already neutral); it does not close or apply. - Closing the dialog with the X discards the draft. The dialog does not pass
unsavedChanges, so the default behaviour ofsrc/components/ui/dialog.tsxapplies (it tracks touched controls). Inferred: the exact confirm-on-close behaviour comes from that component; read it before relying on it.
Two different mechanisms edit how a card looks:
| Edit card (this page) | Designer ("Design") | |
|---|---|---|
| What it changes | Pixels of an existing image: DeckCard.edits
|
A structured CardDesign rendered by the engine |
| Data |
CardEdits (rotation, crop, adjustments) |
DeckCard.design (Designer UI, Designer Engine) |
Applied by imaging::pipeline::render from the original blob |
Re-painted from the design at print size (render_from_image after design::paint) |
|
| Copies | Same-image copies via propagate.ts
|
Same-Scryfall-card group via groups.ts
|
Interaction points, verified in code:
- A designed card is a deck card whose
frontis a JPEG thumbnail withImageOrigin::Designed. "Edit card" can open for it (it has afront). - Saving a design resets
editsto the default (design::preview::applysetsfresh.edits = CardEdits::default()), and the designed-card path of the exporter ignoreseditsand edge darkening (render_orderinsrc-tauri/src/commands/export.rssetsspec.edits = CardEdits::default(),spec.edge = None;render_from_imageskips corners, framing and retouches;edge_forreturnsNoneforDesigned). - The on-screen preview of a designed card still goes through
/r/…with the card'sedits, so a retouch made with "Edit card" (or "Apply to all cards", which touches every card with an image, designed ones included) changes the thumbnail on screen but not the printed PDF. Inferred from those code paths; the UI does not warn about it. To change a designed card's look for print, use the designer. - Designer "Crop from a card…" (
src/features/design/crop-dialog.tsx) lists only non-designed cards with an image and uses their original blob, not their edits. - Original-image edits vs. the "before" snapshot: when a design is created,
design.before.editskeeps the card's edits so "Remove design" restores them.
- The card has no image: the menu entry is disabled and the dialog will not open (
open={!!card?.front}). - The card disappears while open (deleted, undo):
cardByIdreturnsundefinedand the dialog unmounts. - A preview image that fails to load is not shown and the last good image stays visible (
LatestLoadskips failed loads); the dialog shows no error toast. - Zoom range here is 1x-2x, narrower than the designer's artwork zoom (1x-3x); the model itself allows any zoom >= 1.
src/features/card-editor/__tests__/propagate.test.ts: copies are same-image cards; a card without image has no copies; "only this card" leaves other objects identical; "copies" copies everything to same-image cards only; "all" gives the whole edit to this card and only colour to the rest; order and count are preserved. There are no component tests for the dialog (the live behaviour is covered by src/lib/__tests__/live-image.test.ts for the loading utilities and by running the app). Rust: the pipeline's render and adjustment tests live in src-tauri/crates/proxy-core/src/imaging/ (Testing and CI).
- New retouch: add a field to
Adjustmentsinmodel.rs, implement it inimaging/adjust.rs(mind the fixed order and mm radii), regenerate bindings withpnpm bindings, add it toADJUSTMENTSincard-editor-dialog.tsxwith English source text and its entry in every language dictionary,src/i18n/<code>/(pnpm i18nchecks it), and decide whetherapproximateFiltershould approximate it. - Changing which cards an edit reaches: edit only
propagate.tsand its test.
Use and build · Uso y desarrollo
- User-Guide · Guía de usuario
- Development-Setup · Preparación del entorno de desarrollo
- Testing-and-CI · Tests y CI
- Releases-and-Auto-Updates · Versiones y actualizaciones automáticas
- Conventions · Convenciones
- Rename-to-Tapete · Cambio de nombre a Tapete
- License · Licencia
Architecture · Arquitectura
- Architecture · Arquitectura
- IPC-and-Error-Handling · IPC y manejo de errores
- Rust-App-Layer · Capa de aplicación Rust
Data · Datos
- Deck-Model · Modelo del mazo
- Storage-and-Blobs · Almacenamiento y blobs
- Deck-Package-Format · Formato del paquete de mazo
- Deck-Library · Biblioteca de mazos
Getting cards · Conseguir cartas
- Decklist-Parsing · Parseo de la lista del mazo
- Scryfall-Integration · Integración con Scryfall
- External-Sources · Fuentes externas
- Card-Identification-and-OCR · Identificación de cartas y OCR
- Identify-From-a-Photo · Identificar por foto
Layout, images, PDF · Maquetación, imagen y PDF
- Layout-Engine · Motor de maquetación
- Imaging-and-PDF · Imagen y PDF
- Export · Exportación
- The-Card-Stamp · El sello de las cartas
- Live-Preview · Vista previa en vivo
- Statistics · Estadísticas
Card designer · Diseñador de cartas
- Designer-Overview · Visión general del diseñador
- Designer-Engine · Motor del diseñador
- Designer-Composition · Composición del diseñador
- Frame-Packs · Packs de marcos
- Designer-App-Layer · Capa de aplicación del diseñador
- Designer-UI · Interfaz del diseñador
- Card-Editor-Dialog · Diálogo Editar carta
Game table · Mesa de juego
- Game-Engine · Motor de la mesa
- Game-Table · Mesa de juego
- Online-Play · Juego en línea
- Friends-and-Messages · Amigos y mensajes
Mobile · Móvil
Frontend · Frontend
- Frontend-Architecture · Arquitectura del frontend
- State-Stores · Stores de estado
- Internationalization · Internacionalización
- Themes-and-Skins · Temas y skins
- Icons · Iconos
- Settings-and-Shell · Ajustes y shell
- Tutorials · Tutoriales
- Decklist-Panel · Panel de la lista del mazo
- Add-Card-and-Variants · Añadir carta y variantes
- Card-Search · Búsqueda de cartas
- Set-Browser · Explorador de sets
Reference · Referencia