mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Add coords to output when using attention based crop (#3470)
This commit is contained in:
BIN
test/fixtures/expected/crop-strategy.webp
vendored
Normal file
BIN
test/fixtures/expected/crop-strategy.webp
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.0 KiB |
@@ -376,6 +376,8 @@ describe('Resize fit=cover', function () {
|
||||
assert.strictEqual(320, info.height);
|
||||
assert.strictEqual(-107, info.cropOffsetLeft);
|
||||
assert.strictEqual(0, info.cropOffsetTop);
|
||||
assert.strictEqual(588, info.attentionX);
|
||||
assert.strictEqual(640, info.attentionY);
|
||||
fixtures.assertSimilar(fixtures.expected('crop-strategy-attention.jpg'), data, done);
|
||||
});
|
||||
});
|
||||
@@ -394,10 +396,32 @@ describe('Resize fit=cover', function () {
|
||||
assert.strictEqual(80, info.height);
|
||||
assert.strictEqual(0, info.cropOffsetLeft);
|
||||
assert.strictEqual(0, info.cropOffsetTop);
|
||||
assert.strictEqual(0, info.attentionX);
|
||||
assert.strictEqual(0, info.attentionY);
|
||||
fixtures.assertSimilar(fixtures.expected('crop-strategy.png'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('WebP', function (done) {
|
||||
sharp(fixtures.inputWebP)
|
||||
.resize(320, 80, {
|
||||
fit: 'cover',
|
||||
position: sharp.strategy.attention
|
||||
})
|
||||
.toBuffer(function (err, data, info) {
|
||||
if (err) throw err;
|
||||
assert.strictEqual('webp', info.format);
|
||||
assert.strictEqual(3, info.channels);
|
||||
assert.strictEqual(320, info.width);
|
||||
assert.strictEqual(80, info.height);
|
||||
assert.strictEqual(0, info.cropOffsetLeft);
|
||||
assert.strictEqual(-161, info.cropOffsetTop);
|
||||
assert.strictEqual(288, info.attentionX);
|
||||
assert.strictEqual(745, info.attentionY);
|
||||
fixtures.assertSimilar(fixtures.expected('crop-strategy.webp'), data, done);
|
||||
});
|
||||
});
|
||||
|
||||
it('supports the strategy passed as a string', function (done) {
|
||||
sharp(fixtures.inputPngWithTransparency)
|
||||
.resize(320, 80, {
|
||||
|
||||
Reference in New Issue
Block a user