Repository navigation
Conversation
This prevents other image operations to taint the background with the default black background color which manifests itself in black fringes on light edges.
|
Thank you all for this most excellent addition. With tests and documentation it's my favourite kind of pull request. Sorry you had to work on the C++ source - it's got far too large recently and needs refactoring into smaller methods and files. I've also got a plan to vastly simplify all that g_object_unref-ing too. My initial thoughts, based solely on looking at the diffs:
If possible, please can you rebase and squash your commits once you're happy with any changes. Thanks again for adding this very useful feature! |
|
Thanks for your feedback, @lovell. Re: C++. No worries, this a great opportunity for me to learn more about it 😄
I will make the additions per your feedback—thanks!—and then squash the commit. Thanks again for your excellent work 👍 |
Provides internal sharp_image_has_alpha method Hopefully this helps with #91
|
I've added an internally available I took the liberty of adding your transparent PNG test fixture to test this, thank you (hence the rebase conflict you're about to experience). This should hopefully help you with (2) more than it causes rebase headaches. Please can you update this PR to land in the Thanks again for this welcome contribution! |
Provides internal sharp_image_has_alpha method Hopefully this helps with #91
|
Replaced with #94, thank you. |
Background
We at @fiftythree added the
flattenAPI to flatten transparent PNGs (from Paper app) onto a custom background color for our new product, Mix:Please consider this pull request as a starting point to discuss functionality and API. Happy to collaborate with you to make it as good as possible.
API
flatten(background) or flatten(r, g, b)
Flatten transparent images onto
backgroundcolor before processing. Defaults background color to black. Pass any valid CSS color asbackground, e.g.#00ff00,hsl(120,100%,50%), etc., or numbers in the range of[0, 255]forr,g, andb.Acknowledgements
@lovell, thank you for creating
sharp. It has significantly sped up our Mix image conversion pipeline and hence improved the experience for our users. If you have an iPad and would like to try Mix, let me know and I’ll add you to the invite list.Hat tip to @julianwa for adding the 4-bands bugfix and @apitaru for finding black fringing bug and helping fixing it 😄
I’m planning to responding to your survey with more details soon: https://twitter.com/lovell/status/512151120496820224