Making pixels with different colors transparent when comparing 2 images
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 32.7k
- Forks
- 1.4k
- Avg merge
- 1d 14h
- Merged PRs (30d)
- 5
Description
Hi, I got 2 images with are quite similar, but have a different background color. I want to use these different colors to make all those pixels transparent.
So when I have these 2 images:
the result would be this:
I got this working with Imagick, but don't even know where to start with Sharp/libvips:
convert test-black.png test-white.png -alpha off \
\( -clone 0,1 -compose difference -composite -negate \) \
\( -clone 0,2 +swap -compose divide -composite \) \
-delete 0,1 +swap -compose Copy_Opacity -composite \
test-transparent.png
Anybody got some ideas how I could do this in Sharp?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with Sharp and libvips documentation for comparing two images and deriving transparency, using the provided ImageMagick command as the behavioral reference. Confirm whether the required operations are already exposed; done means a reproducible Sharp approach that turns differing background pixels transparent while preserving the shared image content.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js
- Domain
- computer-graphics
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100