Skip to content

feat(render): user-positioned background images (zoom + focal point) - #82

Merged
ajianaz merged 1 commit into
developfrom
feat/bg-image-positioning
Sep 4, 2026
Merged

feat(render): user-positioned background images (zoom + focal point)#82
ajianaz merged 1 commit into
developfrom
feat/bg-image-positioning

Conversation

@ajianaz

@ajianaz ajianaz commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Closes the positioning half of #74 follow-ups (mobile needs it for the background editor).

What

  • New slide-or-brand fields on bg_image templates: bg_image_scale (0.1–5, default 1), bg_image_x/bg_image_y (0–1 focal point, default 0.5)
  • Geometry engine bg_image_geom: cover-fit × user zoom, placed by focal point, values clamped; defaults reproduce the old slice center-crop exactly (verified pixel-identical semantics)
  • blog-hero migrates to the explicit-geometry approach (preserveAspectRatio="none" + computed x/y/w/h); other bg_image templates keep slice until migrated
  • image_to_data_uri_with_size reports intrinsic dimensions (header decode only) for local and remote images; image crate added as a direct dep (already in the tree via resvg)

Why

CLI/server users can now pick which part of a background photo shows (e.g. bg_image_x: 0.0 for a subject on the left), and the mobile background editor (cosy-mobile) drives these same fields from a pinch/drag UI.

Testing

  • resvg spike tests prove none-mode + overflow clipping + focal shifting behave correctly
  • geometry unit tests (defaults == center cover, zoom, focal anchoring, clamping)
  • blog-hero integration render asserts the exact computed geometry in the SVG
  • visual: default render matches previous output; scale 2.5 focal 0/0 renders zoomed toward top-left (screenshots verified)
  • full suite: 111 tests green, clippy clean

Background images were fixed center-crops (preserveAspectRatio slice) —
users could not choose which part of a photo shows or how zoomed it is.

- New slide-or-brand fields: bg_image_scale (0.1–5, default 1),
  bg_image_x / bg_image_y (0–1 focal point, default 0.5)
- text.rs: image_to_data_uri_with_size reports intrinsic dimensions
  (header decode, no full decode) for both local and remote images
- template.rs: bg_image_geom computes cover-fit × user scale placed by
  the focal point; defaults reproduce the old center-crop exactly
  (backward compatible — templates without the fields are unchanged)
- blog-hero migrates to the geometry approach; other bg_image templates
  keep slice until needed
- tests: resvg spike (none + overflow clipping + focal shift),
  geometry unit math, blog-hero integration render, image dimension
  decode; image crate added (already in the tree via resvg)
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

🔍 Cora AI Code Review

No issues found. Code looks good!


Review powered by cora-code · BYOK · MIT

@ajianaz
ajianaz merged commit 0e4d7e6 into develop Sep 4, 2026
12 checks passed
@ajianaz
ajianaz deleted the feat/bg-image-positioning branch September 4, 2026 06:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant