mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Ensure correct dimensions when contain 1px image #2951
This commit is contained in:
@@ -605,6 +605,40 @@ describe('Resize dimensions', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('Ensure embedded shortest edge (height) is at least 1 pixel', function () {
|
||||
return sharp({
|
||||
create: {
|
||||
width: 200,
|
||||
height: 1,
|
||||
channels: 3,
|
||||
background: 'red'
|
||||
}
|
||||
})
|
||||
.resize({ width: 50, height: 50, fit: sharp.fit.contain })
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
.then(function (output) {
|
||||
assert.strictEqual(50, output.info.width);
|
||||
assert.strictEqual(50, output.info.height);
|
||||
});
|
||||
});
|
||||
|
||||
it('Ensure embedded shortest edge (width) is at least 1 pixel', function () {
|
||||
return sharp({
|
||||
create: {
|
||||
width: 1,
|
||||
height: 200,
|
||||
channels: 3,
|
||||
background: 'red'
|
||||
}
|
||||
})
|
||||
.resize({ width: 50, height: 50, fit: sharp.fit.contain })
|
||||
.toBuffer({ resolveWithObject: true })
|
||||
.then(function (output) {
|
||||
assert.strictEqual(50, output.info.width);
|
||||
assert.strictEqual(50, output.info.height);
|
||||
});
|
||||
});
|
||||
|
||||
it('Skip shrink-on-load where one dimension <4px', async () => {
|
||||
const jpeg = await sharp({
|
||||
create: {
|
||||
|
||||
Reference in New Issue
Block a user