Resize images with preserve aspect ratio
This commit is contained in:
parent
56f9cc683a
commit
abffd98e29
4 changed files with 35 additions and 6 deletions
|
@ -98,9 +98,12 @@ describe('nativeImage module', () => {
|
|||
it('returns a resized image', () => {
|
||||
const image = nativeImage.createFromPath(path.join(__dirname, 'fixtures', 'assets', 'logo.png'))
|
||||
assert.deepEqual(image.resize({}).getSize(), {width: 538, height: 190})
|
||||
assert.deepEqual(image.resize({width: 400}).getSize(), {width: 400, height: 190})
|
||||
assert.deepEqual(image.resize({height: 123}).getSize(), {width: 538, height: 123})
|
||||
assert.deepEqual(image.resize({width: 269}).getSize(), {width: 269, height: 95})
|
||||
assert.deepEqual(image.resize({width: 600}).getSize(), {width: 600, height: 212})
|
||||
assert.deepEqual(image.resize({height: 95}).getSize(), {width: 269, height: 95})
|
||||
assert.deepEqual(image.resize({height: 200}).getSize(), {width: 566, height: 200})
|
||||
assert.deepEqual(image.resize({width: 80, height: 65}).getSize(), {width: 80, height: 65})
|
||||
assert.deepEqual(image.resize({width: 600, height: 200}).getSize(), {width: 600, height: 200})
|
||||
assert.deepEqual(image.resize({width: 0, height: 0}).getSize(), {width: 0, height: 0})
|
||||
assert.deepEqual(image.resize({width: -1, height: -1}).getSize(), {width: 0, height: 0})
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue