Rappid toDataURL

49 views
Skip to first unread message

Kirby Craft

unread,
May 9, 2016, 1:02:54 PM5/9/16
to JointJS
I noticed that when using toDataURL to have convert the SVG to a image it defaults to png format. I've tried passing 'image/jpeg' as a parameter to toDataURL and that fails. Do you have a good example of changing the 'type' for toDataURL to something other than the default png format? 

Many thanks,


Roman Bruckner

unread,
May 10, 2016, 3:36:00 AM5/10/16
to joi...@googlegroups.com
Hi Kirby,

When you said your try failed, what exactly happened?

Note that joint.format.Raster plugin uses HTMLCanvasElement.toDataURL() internally (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toDataURL).
A diagram can be exported to `image/png`, `image/jpeg` or `image/webp`.

`app.paper.toDataURL(function(img) { console.log(img); }, { type: 'image/jpeg'} )`

There is also ready-to-use method on joint.dia.Paper.prototype - toJPEG()  (http://jointjs.com/rappid/docs/format/raster).

Best,
Roman


On 9 May 2016 at 19:02, Kirby Craft <kcr...@liveops.com> wrote:
I noticed that when using toDataURL to have convert the SVG to a image it defaults to png format. I've tried passing 'image/jpeg' as a parameter to toDataURL and that fails. Do you have a good example of changing the 'type' for toDataURL to something other than the default png format? 

Many thanks,


--

---
You received this message because you are subscribed to the Google Groups "JointJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jointjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Reply all
Reply to author
Forward
0 new messages