How to get base64 using sharp ?
See original GitHub issueHi there i am using library for reducing image size before uploading to aws s3 bucket. Here is my code please tell me how to get base 64 from sharp api.
sharp(path).rotate().resize(300,300).toBuffer().then( async function(data) { console.log("i want base 64 ", data); try{ const myApp = data.toString('base64'); const mediaDoc = await createMediaObjects(myApp) })
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
node.js - How do I convert a base64 string formatted image to ...
I have that image stored as a base64 encoded string (ie: "data:image/png;base64,iVBOR" etc.). I'm using Sharp npm package. The documentation ...
Read more >How Base64 encoding and decoding is done in node.js
Base64 encoding and decoding can be done in Node.js using the Buffer object. Encoding the original string to base64: The Buffer class in ......
Read more >Convert And Retrieve Image From Base64 Using C#
First, we will convert the image into base64 from a URL and second, convert the image from base64 using memory stream.
Read more >Encoding Strings to Base64 in C# – Arcane Code
We essentially do the reverse of encoding, we call the FromBase64String and pass in our encoded string, which returns a byte array. We...
Read more >Convert.ToBase64String Method (System) - Microsoft Learn
The first 6 bits are equal to decimal 63, which corresponds to the base-64 digit "/" at the end of the output, and...
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 FreeTop 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
Top GitHub Comments
sharp doesn’t support base64 encoding the output image, but as you’ve found out it’s easy to do that yourself outside of the library. Isn’t that fine?
Previously asked here: https://github.com/lovell/sharp/issues/1337
@sunnynegi Hope this helped, please feel free to re-open with more details if not.