0

Suppose I have an image in base 64 format like so:

data:image/png;base64,iVbOSDFJsadFH234...

and I want to get the base64 string of the image rotated by say 90 degrees. How would I do that?

The suggested links use html/canvas. Is there a way to do it with pure javascript?

James Tomasino
  • 3,520
  • 1
  • 20
  • 38
zengod
  • 1,114
  • 13
  • 26
  • @Xaqron, using the first answer from your link gives me: "'callback' couldn't be found" – zengod Jan 12 '20 at 17:31
  • Then try other high-vote answers or leave a comment under problematic answer. – Xaqron Jan 12 '20 at 18:11
  • @Xaqron. I've edited the question, whose scope is different from your link. I would like to do it without any html components – zengod Jan 12 '20 at 18:19
  • Change your question. Base64 is nothing, it's just string data, any binary data can be trivially turned into, and converted from, base64 using Nodejs so we can ignore that: it's not relevant to your problem. The real question is "how do I rotate an image in Node", to which the answer is "by using any of quite a few image libraries that are easily found on npmjs.com". If those need "flies", then you write your data to file and unlink when done, but almost all know how to work with Buffer, because that's Node's favourite binary datastructure. – Mike 'Pomax' Kamermans Jan 12 '20 at 18:37
  • If you need to do this in back-end then first [convert base64 to buffer](https://www.npmjs.com/package/base64-img), rotate the image and convert the buffer to base64 again. – Xaqron Jan 12 '20 at 18:40

0 Answers0