Error : Image to composite must have same dimensions or smaller
See original GitHub issuePossible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
- [ x] Running
npm install sharpcompletes without error. - [ x] Running
node -e "require('sharp')"completes without error.
If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
- [x ] I am using the latest version of
sharpas reported bynpm view sharp dist-tags.latest.
If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.
If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.
What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?
System: OS: Windows 10 10.0.19044 CPU: (12) x64 Intel® Core™ i7-8750H CPU @ 2.20GHz Memory: 7.02 GB / 15.82 GB Binaries: Node: 14.18.0 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.11 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.14.15 - C:\Program Files\nodejs\npm.CMD npmPackages: sharp: ^0.30.4 => 0.30.4
Explanation of the issue
I’m trying to composite a .gif animated image w/ animated layers. However, when I add the ‘animated: true’ parameter to the layers to be composed, I get the following error:
Image to composite must have same dimensions or smaller
When I do not set the animated parameter to true the image is static and does not animate. The background and the body are non-animated .gif images, the rest (the composite layers) are supposed to be animated.
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
let overlay =
[
{
input : body,
tile: true,
animated : true,
},
{
input: mouth,
tile : true,
animated : true
},
{
input : eyes,
tile : true,
animated : true
}
];
let img = await sharp(background).toBuffer();
img = await sharp(img).composite(overlay).toBuffer();
/// img = await sharp(img).resize(1000, 1000).toBuffer();
await sharp(img).gif()
.toFile('animate_output/' + id + '.gif', (err) => {
if (err === null) {
console.log("IMAGE n°" + id + "done");
} else {
console.log("ERR: ", err)
}
});
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Related StackOverflow Question
The input image (
backgroundin this case) needs to have at least the same height as the combined height of all the frames. As it appears to be a solid colour, you could create a new, blank image as the input canvas, something like: