A
A
Alexander Fedoruk2014-03-29 18:01:22
JavaScript
Alexander Fedoruk, 2014-03-29 18:01:22

Fabric js - how to save image to jpg?

There is fabric js canvas with id canvas . How to save a canvas image as a jpg? Or png?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
Konstantin Velichko, 2014-03-29
@Zoxon

var image = canvas.toDataURL("image/png").replace("image/png", "image/octet-stream");
window.location.href=image;

A
Alexey Kureev, 2014-04-15
@xamd

The canvas has a toDataURL method that takes an options hash. Pass in the desired format in it: jpeg or png. You can read more about it in the documentation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question