javascript - How to add a glowing filter to an image -


this effect want (the 2nd one):

in photoshop

1) duplicate layer
2) reduce exposure of new layer
3) add blur
4) blend mode linear dodge (add)

a programmer knew achieved effect long ago, never told how code gave me instructions achieve same thing in photoshop

its been while , started learn web dev own , effect calls atention (and yes, lost posible contact person)

at first thought achieved css filter effects https://www.w3schools.com/cssref/css3_pr_filter.asp

however while contains blur(%) cant seem find way achieve exposition or worse linear dodge blend mode.

does know how in earth filter made? guessing didnt use css , instead did javascript.

any appreciated.

edit: oh right, playing values, got nice filter keep playing around them! thank you

you can use various techniques blur 1 version , composite on top of original using additive blending.

here 1 example using image background image , after element inherits image, adds blur , composite using mix blending , lighten (lighter aka "add" aka "linear-dodge", can used well):

div {    background:url(//i.stack.imgur.com/rebgc.png);    width:190px;    height:190px;    }    /* create overlay blurring background */  div:after {    position:absolute;    content:"";    width:190px;    height:190px;    background:inherit;    filter:blur(9px);        /* glow range */    opacity:0.8;    mix-blend-mode: lighten; /* lighter (add) can used */    }
<div></div>

the same can achieved using canvas element instead, since not browsers support new filter property on 2d context may have blur manually (added brightness demo below well).

var img = new image; img.onload = draw; img.src = "//i.stack.imgur.com/rebgc.png";  var blur = document.getelementbyid("blur"), blend = document.getelementbyid("blend"),      luma  = document.getelementbyid("luma");    function draw() {    var ctx = c.getcontext("2d");    ctx.drawimage(this, 0, 0);    ctx.filter = "brightness(" + luma.value + ") blur(" + blur.value + "px)";   // note: not browsers support yet (ff/chrome ok)    ctx.globalcompositeoperation = "lighten";    ctx.globalalpha = +blend.value;    ctx.drawimage(this, 0, 0);    ctx.filter = "none";  // reset    ctx.globalcompositeoperation = "source-over";  }    blur.oninput = blend.oninput = luma.oninput = draw.bind(img);
<div>blur: <input id=blur type=range min=0 max=30 value=9></div>  <div>blend: <input id=blend type=range min=0 max=1 step=0.1 value=0.8></div>  <div>luma: <input id=luma type=range min=0.5 max=2 step=0.1 value=1></div>  <canvas width=190 height=190 id=c></canvas>


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -