Resolve toBuffer Promise with an array (was: When using promises, how do you get image info)
See original GitHub issueif a callback is used with toBuffer
for example the image info
is passed to the callback, how do you get this info when using a promise ?
Issue Analytics
- State:
- Created 9 years ago
- Reactions:3
- Comments:12 (9 by maintainers)
Top Results From Across the Web
How to get the index of the Promise returned by Promise.any ...
I 've tried finding the index by comparing each promise of the array to the one returned by Promise.any , but that didn't...
Read more >Promise.resolve() - JavaScript - MDN Web Docs
The Promise.resolve() method "resolves" a given value to a Promise. If the value is a promise, that promise is returned; if the value...
Read more >Processing images with sharp in Node.js - LogRocket Blog
sharp is a high-performance image processing module for Node.js. ... We use the metadata() function to extract the image metadata.
Read more >Input metadata - High performance Node.js image processing
Fast access to (uncached) image metadata without decoding any compressed pixel data. This is taken from the header of the input image. It...
Read more >JavaScript Promise Tutorial – How to Resolve or Reject ...
We will use the PokeAPI to get information about Pokémon and resolve/reject them using Promises. First, let us create a generic function that ......
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
@Vispercept The
data
andinfo
attributes “returned” by toBuffer are highly related to each other;info
contains properties computed whilst processing the final output image. Perhaps you’re thinking of the existing metadata call to access input image info?Rather than the Promise resolving with an Array, how about resolving with an Object, which would allow for destructuring e.g.:
Commit 6fe5b30 adds the new
resolveWithObject
option totoBuffer
. This will be in v0.17.3.