Support PNG, JPEG, BMP, WEBP export formats by change of "Export to PNG" menu item into "Export" with its own pull-down dialog (and a HTML5 range type input element for "quality" selection for JPEG or WEBP files), including changes for the server_opensave extension; change locale key from "export_png" to "export_img" and change the corresponding localized strings (currently CS, DE, ES, FR, IT, NL, PT-BR, RO, SK, all reset to English to avoid translation errors); within the setCustomHandlers() API, deprecate "pngsave" in favor of "exportImage" (chosen to avoid just using the simpler but reserved JS keyword "export") including use within the server_opensave extension; a few JSLint-friendly changes
git-svn-id: http://svg-edit.googlecode.com/svn/trunk@2602 eee81c28-f429-11dd-99c0-75d572ba1ddd
This commit is contained in:
@@ -11,7 +11,7 @@ svgEditor.addExtension("server_opensave", {
|
||||
callback: function() {
|
||||
|
||||
var save_svg_action = 'extensions/filesave.php';
|
||||
var save_png_action = 'extensions/filesave.php';
|
||||
var save_img_action = 'extensions/filesave.php';
|
||||
|
||||
// Create upload target (hidden iframe)
|
||||
var target = $('<iframe name="output_frame" src="#"/>').hide().appendTo('body');
|
||||
@@ -32,8 +32,10 @@ svgEditor.addExtension("server_opensave", {
|
||||
.appendTo('body')
|
||||
.submit().remove();
|
||||
},
|
||||
pngsave: function(win, data) {
|
||||
var issues = data.issues;
|
||||
exportImage: function(win, data) {
|
||||
var issues = data.issues,
|
||||
mimeType = data.mimeType,
|
||||
quality = data.quality;
|
||||
|
||||
if(!$('#export_canvas').length) {
|
||||
$('<canvas>', {id: 'export_canvas'}).hide().appendTo('body');
|
||||
@@ -43,7 +45,7 @@ svgEditor.addExtension("server_opensave", {
|
||||
c.width = svgCanvas.contentW;
|
||||
c.height = svgCanvas.contentH;
|
||||
canvg(c, data.svg, {renderCallback: function() {
|
||||
var datauri = c.toDataURL('image/png');
|
||||
var datauri = quality ? c.toDataURL(mimeType, quality) : c.toDataURL(mimeType);
|
||||
|
||||
var uiStrings = svgEditor.uiStrings;
|
||||
var note = '';
|
||||
@@ -63,9 +65,10 @@ svgEditor.addExtension("server_opensave", {
|
||||
|
||||
var form = $('<form>').attr({
|
||||
method: 'post',
|
||||
action: save_png_action,
|
||||
action: save_img_action,
|
||||
target: 'output_frame'
|
||||
}) .append('<input type="hidden" name="output_png" value="' + datauri + '">')
|
||||
}) .append('<input type="hidden" name="output_img" value="' + datauri + '">')
|
||||
.append('<input type="hidden" name="mime" value="' + mimeType + '">')
|
||||
.append('<input type="hidden" name="filename" value="' + filename + '">')
|
||||
.appendTo('body')
|
||||
.submit().remove();
|
||||
|
||||
Reference in New Issue
Block a user