mirror of
https://github.com/foliojs/pdfkit.git
synced 2025-12-08 20:15:54 +00:00
Add 'cover' option for images
This commit is contained in:
parent
a944efdac5
commit
3cdef01461
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user