Skip to content

Commit

Permalink
Improve alpha blending of filters
Browse files Browse the repository at this point in the history
  • Loading branch information
akiomik committed Nov 19, 2019
1 parent 8002366 commit 09d5829
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 35 deletions.
3 changes: 1 addition & 2 deletions pilgram/brooklyn.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ def brooklyn(im):

cb = util.or_convert(im, 'RGB')

cs1 = util.fill(cb.size, [168, 223, 193])
cs1 = util.fill(cb.size, [168, 223, 193, .4])
cm1 = css.blending.overlay(cb, cs1)
cm1 = Image.blend(cb, cm1, .4)

cs2 = util.fill(cb.size, [196, 183, 200])
cm2 = css.blending.overlay(cb, cs2)
Expand Down
7 changes: 2 additions & 5 deletions pilgram/clarendon.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from PIL import Image

from pilgram import css
from pilgram import util

Expand All @@ -30,9 +28,8 @@ def clarendon(im):

cb = util.or_convert(im, 'RGB')

cs = util.fill(cb.size, [127, 187, 227])
cm = css.blending.overlay(cb, cs)
cr = Image.blend(cb, cm, .2)
cs = util.fill(cb.size, [127, 187, 227, .2])
cr = css.blending.overlay(cb, cs)

cr = css.contrast(cr, 1.2)
cr = css.saturate(cr, 1.35)
Expand Down
7 changes: 2 additions & 5 deletions pilgram/maven.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from PIL import Image

from pilgram import css
from pilgram import util

Expand All @@ -30,9 +28,8 @@ def maven(im):

cb = util.or_convert(im, 'RGB')

cs = util.fill(cb.size, [3, 230, 26])
cm = css.blending.hue(cb, cs)
cr = Image.blend(cb, cm, .2)
cs = util.fill(cb.size, [3, 230, 26, .2])
cr = css.blending.hue(cb, cs)

cr = css.sepia(cr, .25)
cr = css.brightness(cr, .95)
Expand Down
6 changes: 2 additions & 4 deletions pilgram/mayfair.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ def mayfair(im):
size = cb.size
pos = (.4, .4)

cs1 = util.fill(size, [255, 255, 255])
cs1 = util.fill(size, [255, 255, 255, .8])
cm1 = css.blending.overlay(cb, cs1)
cm1 = Image.blend(cb, cm1, .8)

cs2 = util.fill(size, [255, 200, 200])
cs2 = util.fill(size, [255, 200, 200, .6])
cm2 = css.blending.overlay(cb, cs2)
cm2 = Image.blend(cb, cm2, .6)

cs3 = util.fill(size, [17, 17, 17])
cm3 = css.blending.overlay(cb, cs3)
Expand Down
7 changes: 2 additions & 5 deletions pilgram/reyes.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from PIL import Image

from pilgram import css
from pilgram import util

Expand All @@ -30,9 +28,8 @@ def reyes(im):

cb = util.or_convert(im, 'RGB')

cs = util.fill(cb.size, [239, 205, 173])
cs = css.blending.soft_light(cb, cs)
cr = Image.blend(cb, cs, .5)
cs = util.fill(cb.size, [239, 205, 173, .5])
cr = css.blending.soft_light(cb, cs)

cr = css.sepia(cr, .22)
cr = css.brightness(cr, 1.1)
Expand Down
3 changes: 1 addition & 2 deletions pilgram/rise.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,8 @@ def rise(im):
gradient_mask1 = util.radial_gradient_mask(cb.size, length=.55)
cm = Image.composite(cm1, cm2, gradient_mask1)

cs3 = util.fill(cb.size, [232, 197, 152])
cs3 = util.fill(cb.size, [232, 197, 152, .8])
cm3 = css.blending.overlay(cm, cs3)
cm3 = Image.blend(cm, cm3, .8)

gradient_mask2 = util.radial_gradient_mask(cb.size, scale=.9)
cm_ = Image.composite(cm3, cm, gradient_mask2)
Expand Down
3 changes: 1 addition & 2 deletions pilgram/slumber.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,8 @@ def slumber(im):
cm = ImageChops.lighter(cb, cs1)
cm = Image.blend(cb, cm, .4)

cs2 = util.fill(cb.size, [125, 105, 24])
cs2 = util.fill(cb.size, [125, 105, 24, .5])
cr = css.blending.soft_light(cm, cs2)
cr = Image.blend(cm, cr, .5)

cr = css.saturate(cr, .66)
cr = css.brightness(cr, 1.05)
Expand Down
7 changes: 2 additions & 5 deletions pilgram/stinson.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from PIL import Image

from pilgram import css
from pilgram import util

Expand All @@ -30,9 +28,8 @@ def stinson(im):

cb = util.or_convert(im, 'RGB')

cs = util.fill(cb.size, [240, 149, 128])
cm = css.blending.soft_light(cb, cs)
cr = Image.blend(cb, cm, .2)
cs = util.fill(cb.size, [240, 149, 128, .2])
cr = css.blending.soft_light(cb, cs)

cr = css.contrast(cr, .75)
cr = css.saturate(cr, .85)
Expand Down
7 changes: 2 additions & 5 deletions pilgram/valencia.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from PIL import Image

from pilgram import css
from pilgram import util

Expand All @@ -30,9 +28,8 @@ def valencia(im):

cb = util.or_convert(im, 'RGB')

cs = util.fill(cb.size, [58, 3, 57])
cs = css.blending.exclusion(cb, cs)
cr = Image.blend(cb, cs, .5)
cs = util.fill(cb.size, [58, 3, 57, .5])
cr = css.blending.exclusion(cb, cs)

cr = css.contrast(cr, 1.08)
cr = css.brightness(cr, 1.08)
Expand Down

0 comments on commit 09d5829

Please sign in to comment.