This adds two commands to svg-preview: svg-preview:export-to-png
andsvg-preview:export-to-jpeg. When triggered, they execute the following
actions (added to lib/svg-preview-view.js in the exportTo
function):
Convert the current svg to the specified raster format
(respectively
png or jpeg).
The canvas API toDataURL function takes care of the
conversion.
Implementation details in lib/svg-to-raster.js.
Open a Save As dialog and (after the user closes the Save As
dialog)
saves the raster graphic to the specified location
Opens the raster graphic
As a first proposal this change binds the commands to context menu
items in the previewer (menus/svg-preview.cson)
Notes:
It uses fs-plus for saving the raster graphics. fs-plus already
was a development dependency - this change promotes it to a regular
one.
Both fs-plus and svg-to-raster are only loaded when the conversion
actions are triggered for the first time, in order for them not to
impact package load time.
Specs/ tests for both commands in spec/svg-preview-spec.js
(= #33, decaffeinated to es6)
This adds two commands to svg-preview:
svg-preview:export-to-png
andsvg-preview:export-to-jpeg
. When triggered, they execute the following actions (added tolib/svg-preview-view.js
in theexportTo
function):lib/svg-to-raster.js
.As a first proposal this change binds the commands to context menu items in the previewer (
menus/svg-preview.cson
)Notes:
spec/svg-preview-spec.js