Expose setting xres/yres for JPEG/PNG output
See original GitHub issueHi!
I saw that in the documentation it is possible to adjust the density metadata in the constructor, but it doesn’t work in my case for some reason. Below is the code which works but the density is never adjusted. Does anyone know how I can do this with the code snippet below?
Thanks!
const sharpImage = sharp(imagedData /* tried adding density here ... , {density: 170} */)
sharpImage
.rotate()
.metadata()
.then(function(metadata) {
return sharpImage
.extract({
left: Math.round(metadata.width * parasedBody.x),
top: Math.round(metadata.height * parasedBody.y),
width: Math.round(metadata.width * parasedBody.width),
height: Math.round(metadata.height * parasedBody.height)})
.toBuffer((err, outputBuffer, info) => {
console.log("BUFF FUNC ERR", err);
console.log("BUFF FUNC outputBuffer", outputBuffer);
console.log("BUFF FUNC info", info);
})
})
Issue Analytics
- State:
- Created 6 years ago
- Comments:18 (9 by maintainers)
Top Results From Across the Web
How do I specify the output sizes of JPEG, PNG, and TIFF ...
The JPEG, PNG, and TIFF drivers in MATLAB 5.x and later rely upon a figure's "PaperPosition" to specify the size of the output...
Read more >Save or Export an Image as JPEG, PNG, GIF, etc - YouTube
Chris Recommends ◥Protect Your Online Privacy with NordVPN ▻▻https://go.nordvpn.net/SH4A0Save Money Shopping Online with Honey Extension ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

v0.28.2 is now available.
Commit https://github.com/lovell/sharp/commit/4237f5520f6dfcae2706e6d7ffe3cc3d3e05a604 adds a new output
densityproperty towithMetadata()to set the DPI resolution, which keeps things consistent with the inputdensityproperty ofmetadata().This will be in v0.28.2.