You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi @lovell,
Does sharp support the option to dissolve a transparent image?
I was looking for something similar to imagemagick's dissolve option.
I took a look at the docs but could not find anything.
What i wanna achieve is to overlay a watermark, which works well but i would also like to dissolve it by ~35%.
@lovell thank you for the link but i wanna add the opacity via sharpjs and not on the watermark input file itself. The idea behind it is that the watermark can be reused with different dissolve percentages.
If this module were to provide the ability to multiply alpha channel values then it would make sense to allow this for any images, not just those supplied to overlayWith.
I'm happy to accept a PR to implement such an operation and can help with API design. It would need to pretty much do what the *magick command is doing, which is detach the alpha channel, multiply its pixels by a specified value (clipped to a maximum value based on 8 vs 16 bits-per-channel), then re-attach to the original image.
What are the chances that an opacity option (1-100%) is available to the overlayWith function? Or is this already available, and if so, how would I access this?
It would need to pretty much do what the *magick command is doing, which is detach the alpha channel, multiply its pixels by a specified value (clipped to a maximum value based on 8 vs 16 bits-per-channel), then re-attach to the original image.
libvips has aslightly neater way of doing this: you can multiply by a vector, with 1.0 for bands you want to leave alone.
In C++ you can write:
rgba_image *= {1.0, 1.0, 1.0, opacity};
I think (?) that'll work in C++11. You might need a cast in there. You'd obviously need to check that it was an RGBA image somewhere.
Reacted by tinypoint, yonder, Beomseok Lee, APixel Visuals, Mykhailo Gorianskyi, jivea, huang puguang, Jesse Sibley, Andreas May, Szymon Nowak and 5 more
Reacted by yonder, Mykhailo Gorianskyi, Matteo Gazzoni, PolarPhoenix and zsnmwy
Coming back to the original request, how to blend a watermark with transparency over a base image?
From previous comment, I can't tell if 'source' is watermark or base, nor couldn't figure out how to combine the two.
Thanks
It seems like it'd be a relatively common image-manipulation task.
I'm using the following code an can't for the life of me figure out how I'd apply the logo watermark at a variable-based opacity level. (the logo opacity will be user-selected, so I can't just modify the logo png.
Is it not currently possible (even if there isn't an 'easy' way to do it?)? I'm trying to stay with Sharp but I'll have to leave (an re-write a lot of code) for a different library if it doesn't have this functionality.
Activity
lovell commentedon Nov 2, 2016
Hello, have you tried adding an alpha transparency channel of the desired opacity to the watermark?
davidecantoni commentedon Nov 2, 2016
@lovell thank you for your quick answer!
I tried but wasn't successful, this is the current outcome.
How can i add an alpha transparency channel of the desired opacity to the watermark?
lovell commentedon Nov 2, 2016
https://github.com/janosgyerik/cheatsheets/wiki/ImageMagick-cheat-sheet
davidecantoni commentedon Nov 2, 2016
@lovell thank you for the link but i wanna add the opacity via sharpjs and not on the watermark input file itself. The idea behind it is that the watermark can be reused with different dissolve percentages.
lovell commentedon Nov 2, 2016
If this module were to provide the ability to multiply alpha channel values then it would make sense to allow this for any images, not just those supplied to
overlayWith.I'm happy to accept a PR to implement such an operation and can help with API design. It would need to pretty much do what the *magick command is doing, which is detach the alpha channel, multiply its pixels by a specified value (clipped to a maximum value based on 8 vs 16 bits-per-channel), then re-attach to the original image.
[-]Imagemagick's dissolve option[/-][+]Multiply alpha channel (was: Imagemagick's dissolve option)[/+]samlin86 commentedon Jan 5, 2018
Seeing that libvips has released v8.6 at the end of November, I see there was a commit to master that uses this.
What are the chances that an
opacityoption (1-100%) is available to theoverlayWithfunction? Or is this already available, and if so, how would I access this?lovell commentedon Jan 6, 2018
@samlin86 The
overlayWithoperation will be switching to use the newvips_compositeas part of #728 and that will include all the new blend modes.jcupitt commentedon Jul 25, 2019
libvips has aslightly neater way of doing this: you can multiply by a vector, with 1.0 for bands you want to leave alone.
In C++ you can write:
rgba_image *= {1.0, 1.0, 1.0, opacity};I think (?) that'll work in C++11. You might need a cast in there. You'd obviously need to check that it was an RGBA image somewhere.
Colkadome commentedon Sep 17, 2019
You can multiply the alpha channel using this, where opacity is the alpha channel (0-255).
tinypoint commentedon Nov 24, 2019
It works!!!
mariusa commentedon Dec 5, 2021
Coming back to the original request, how to blend a watermark with transparency over a base image?
From previous comment, I can't tell if 'source' is watermark or base, nor couldn't figure out how to combine the two.
Thanks
jfederer commentedon Feb 15, 2022
Has this feature ever been added to Sharp?
It seems like it'd be a relatively common image-manipulation task.
I'm using the following code an can't for the life of me figure out how I'd apply the logo watermark at a variable-based opacity level. (the logo opacity will be user-selected, so I can't just modify the logo png.
lovell commentedon Feb 15, 2022
@jfederer This issue is a future possible enhancement. A PR to implement it is welcome, if you're able.
jfederer commentedon Feb 15, 2022
Is it not currently possible (even if there isn't an 'easy' way to do it?)? I'm trying to stay with Sharp but I'll have to leave (an re-write a lot of code) for a different library if it doesn't have this functionality.