Skip to content

fix(studio): make image background removal reliable - #3969

Open
miguel-heygen wants to merge 2 commits into
mainfrom
fix/studio-image-background-removal
Open

miguel-heygen wants to merge 2 commits into
mainfrom
fix/studio-image-background-removal

Conversation

@miguel-heygen

Copy link
Copy Markdown
Collaborator

Summary

  • Add a shared resolveProjectAssetPath helper so both classic and flat media property panels normalize project-local image/video src values (relative paths and Studio /api/projects/.../preview/... URLs) before calling remove-background.
  • Reject external http(s), data:, blob:, file:, protocol-relative, and non-preview /api URLs; strip query/hash; safely URI-decode; normalize ./ / .. segments.
  • Cover positive image Remove BG flows in both panels, path-normalization unit tests, and the studio-server JPG → default PNG cutout success path.

Test plan

  • bun run --cwd packages/studio test src/utils/projectAssetPath.test.ts src/components/editor/propertyPanelFlatMediaSection.test.tsx src/components/editor/propertyPanelMediaSection.test.tsx
  • bun run --cwd packages/studio-server test src/routes/media.test.ts
  • bunx oxlint + bunx oxfmt --check on changed files
  • In Studio: select a project-local image (including one whose preview src is an /api/projects/.../preview/... URL), confirm Remove BG is enabled, and that the cutout applies as a PNG under assets/cutouts/

Normalize project-local media src (including Studio preview URLs) so
Remove BG works for images in both property panels, and cover the
JPG-to-PNG default cutout path on the media route.
Preview bundles turn relative images into data URLs, which disabled
Remove BG for images. Persist data-hf-authored-src on inline and prefer
it when resolving the project asset path in both media inspectors.
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