Are you using the latest version? Is the version currently in use as reported by npm ls sharp the same as the latest version as reported by npm view sharp dist-tags.latest?
Yes, 0.29.3.
What are the steps to reproduce?
- Install sharp
- Load from buffer
const buffer = Buffer.from(image, "base64");
const sharpSkin = sharp(buffer);
- Apply some modifications to image (propably not strictly necessary)
const sharpHead = sharpSkin.extract({ left: 8, top: 8, width: 8, height: 8 });
- Output to file and to buffer.
await sharpHead.toFile("test.png");
return sharpHead
.toBuffer()
.then((data) => {
return data.toString("base64");
})
.catch((error) => {
throw new Error(
"Couldn't extract head of skin for uuid " + uuid + ". Reason: " + error
);
});
What is the expected behaviour?
Either of two options:
- Return
data as expected instead of the info object.
- Throw error and don't return anything.
Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?
const buffer = Buffer.from(image, "base64");
const sharpSkin = sharp(buffer);
const sharpHead = sharpSkin.extract({ left: 8, top: 8, width: 8, height: 8 });
await sharpHead.toFile("test.png"); // works as expected
return sharpHead
.toBuffer()
.then((data) => {
console.log(JSON.stringify(data)); // `{"format":"png","width":8,"height":8,"channels":4,"premultiplied":false,"size":326}`
return data.toString("base64"); // returns "[object Object]"
})
.catch((error) => {
throw new Error(
"Couldn't extract head of skin for uuid " + uuid + ". Reason: " + error
);
});
If you explicitly force sharp to output the info object, data still returns info and info is undefined in this case.
Are you able to provide a sample image that helps explain the problem?
From my understanding this happens with every image, therefore not applicable.
What is the output of running npx envinfo --binaries --system?
System:
OS: Windows 10 10.0.19043
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 6.76 GB / 15.93 GB
Binaries:
Node: 16.13.0 - G:\Programme\nodejs\node.EXE
npm: 8.1.0 - G:\Programme\nodejs\npm.CMD
Are you using the latest version? Is the version currently in use as reported by
npm ls sharpthe same as the latest version as reported bynpm view sharp dist-tags.latest?Yes,
0.29.3.What are the steps to reproduce?
What is the expected behaviour?
Either of two options:
dataas expected instead of theinfoobject.Are you able to provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem?
If you explicitly force sharp to output the
infoobject,datastill returnsinfoandinfoisundefinedin this case.Are you able to provide a sample image that helps explain the problem?
From my understanding this happens with every image, therefore not applicable.
What is the output of running
npx envinfo --binaries --system?