question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to get base64 using sharp ?

See original GitHub issue

Hi 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:closed
  • Created 5 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
papandreoucommented, Jan 15, 2019

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

0reactions
lovellcommented, Jan 27, 2019

@sunnynegi Hope this helped, please feel free to re-open with more details if not.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found