Skip to content

Commit 4340d60

Browse files
committed
Ensure composite tile images fully decoded #3767
1 parent 7f64d46 commit 4340d60

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

docs/changelog.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ Requires libvips v8.14.4
66

77
### v0.32.6 - TBD
88

9+
* Ensure composite tile images are fully decoded (regression in 0.32.0).
10+
[#3767](https://github.com/lovell/sharp/issues/3767)
11+
912
* Ensure `withMetadata` does not add default sRGB profile to RGB16 (regression in 0.32.5).
1013
[#3773](https://github.com/lovell/sharp/issues/3773)
1114

src/pipeline.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ class PipelineWorker : public Napi::AsyncWorker {
653653
if (across != 0 || down != 0) {
654654
int left;
655655
int top;
656-
compositeImage = compositeImage.replicate(across, down);
656+
compositeImage = compositeImage.copy_memory().replicate(across, down);
657657
if (composite->hasOffset) {
658658
std::tie(left, top) = sharp::CalculateCrop(
659659
compositeImage.width(), compositeImage.height(), image.width(), image.height(),

test/unit/composite.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,4 +472,28 @@ describe('composite', () => {
472472
assert.strictEqual(b, 19);
473473
assert.strictEqual(a, 128);
474474
});
475+
476+
it('Ensure tiled overlay is fully decoded', async () => {
477+
const tile = await sharp({
478+
create: {
479+
width: 8, height: 513, channels: 3, background: 'red'
480+
}
481+
})
482+
.png({ compressionLevel: 0 })
483+
.toBuffer();
484+
485+
const { info } = await sharp({
486+
create: {
487+
width: 8, height: 514, channels: 3, background: 'green'
488+
}
489+
})
490+
.composite([{
491+
input: tile,
492+
tile: true
493+
}])
494+
.toBuffer({ resolveWithObject: true });
495+
496+
assert.strictEqual(info.width, 8);
497+
assert.strictEqual(info.height, 514);
498+
});
475499
});

0 commit comments

Comments
 (0)