gwendall
gwendall

Reputation: 920

edit base64 encoded image on the fly with javascript

Is it possible to edit (resize, flip, etc.) a base64 encoded image directly through javascript?

Upvotes: 2

Views: 4800

Answers (2)

adeneo
adeneo

Reputation: 318302

Yes you can, once it is in the DOM structure it does not matter if it's base64 or an external image, you can manipulate like you would any other DOM element.

Using it as a background image (and then manipulating the holding element), directly in a img tag or inserting it with javascripts new image (and then create element img) does not matter, as long it is in the DOM.

You can convert your images online in one of the many converters, this one uses html5 only : base64img.com

Upvotes: 0

Lachezar
Lachezar

Reputation: 6703

Yes, it is possible using HTML5. Just load the base64 string as image source <img src="data:image/png;base64,iVBORw0KGgo... and then add it into canvas element (by using the drawImage method of the canvas's context) and do whatever you want with it.

Upvotes: 4

Related Questions