w3c / w3c/csswg-drafts

[css-images] Add a way to composite multiple images

Open
#7,666 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

css-images-5
Dominant language
Bikeshed
Stars
4.9k
Forks
816
Avg merge
2d 18h
Merged PRs (30d)
24

Description

In #6807 the use case to composite and blend multiple images into one was mentioned in several comments.

As this seems orthogonal to the use case of manipulating a single image, I filed this issue, so it can be discussed separately.

The general idea is to establish different layers for images similar to how graphics programs have them. For each layer you can define an image (or maybe even multiple ones?) and additional information, e.g. a blending method or the position and size.

In the other issue @Crissov provided this syntax example:

@image --composite {
  @layer --stage {
    src: "backdrop.jpg";
  }
  @layer --scene {
    src: "parallax.png";
  }
  @layer --actor {
    src: "map.svg#sprite";
    position: 200px 300px;
  }
}

Here's a general syntax suggestion to get the ball rolling:

@image <custom-ident> {
  @image-layer <custom-ident>? {
    src: <image>;
    position: <'position'>;
    mix-blend-mode: <'mix-blend-mode'>
    width: <'width'>;
    height: <'height'>;
  }
  ...
}

@image in this example would be a general container for custom images. It might end up being the same one as for image manipulations or be a completely separate one, though in the suggested syntax it's used to generate the composited image.
This image can then be used in <image> values, either directly, i.e. --composite, or via a function like src(--composite) or image(--composite).

Sebastian

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading this issue's discussion and the related issue #6807, including the proposed @image and @image-layer syntax. The work is not ready for a small implementation: done would require an agreed design for compositing, layers, positioning, blending, and how the result is used as an image value.

Written by the indexing model from the issue text.

Assessment

Tech stack
css
Domain
frontend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.