-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error "text: invalid value (typically too big) for the size of the input" #4071
Comments
- const buf = await text.toBuffer()
+ const buf = await text.png().toBuffer() |
same error with that, I've also tried |
Please can you provide the error message. |
|
And what are the specific values of |
width: 201, height: 18.9, however when I resize the text image like |
- height: height * 0.1,
+ height: Math.round(height * 0.1), |
I made the change you suggested, and I still get the same error. const sharp = require('sharp');
async function addText() {
const img = sharp('./images/robo.jpg')
const metadata = await img.metadata()
const width = metadata.width;
const height = metadata.height;
let text = sharp({
text: {
text: '<span foreground="#ffffff" background="#00000066">19.0748\n72.8856\n2024-04-16 13:37</span>',
rgba: true,
width: width,
height: Math.round(height * 0.1),
align: 'right',
},
})
console.log(text)
const buf = await text.png().toBuffer()
console.log(await text.metadata())
img.composite([{
input: buf,
gravity: 'southeast',
}])
.toFile(__dirname + '/pimages/text_robo.jpg')
}
addText(); /app/node_modules/sharp/lib/input.js:486
const stack = Error();
^
Error: text: invalid value (typically too big) for the size of the input (surface, pattern, etc.)
at Sharp.metadata (/app/node_modules/sharp/lib/input.js:486:17)
at addText (/app/_text.js:23:28)
Node.js v20.12.2 |
Commit a1309aa tightens the validation of some of the |
I believe that was the issue, I was able to make it work by rounding the dimensions. However, in an alpine docker image, I had to add the |
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.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?
sharp
as 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
?What are the steps to reproduce?
What is the expected behaviour?
The text should composite over the image without an error.
Please provide sample image(s) that help explain this problem
https://imgur.com/a/AsjIlNl
I even tried to resize the text sharp object to 20x20 and I still got the error.
The text was updated successfully, but these errors were encountered: