Add 'cover' option for images

This commit is contained in:
alafr 2016-09-16 00:40:15 +03:00 committed by GitHub
parent a944efdac5
commit 3cdef01461

View File

@ -51,16 +51,26 @@ module.exports =
else
h = bh
w = bh * ip
else if options.cover
[bw, bh] = options.cover
bp = bw / bh
ip = image.width / image.height
if ip > bp
h = bh
w = bh * ip
else
w = bw
h = bw / ip
if options.fit or options.cover
if options.align is 'center'
x = x + bw / 2 - w / 2
else if options.align is 'right'
x = x + bw - w
if options.valign is 'center'
y = y + bh / 2 - h / 2
else if options.valign is 'bottom'
y = y + bh - h