From 19c4b1ca6559be17cd2732366930514f370397df 2012-06-08 18:01:05 From: Brian Granger Date: 2012-06-08 18:01:05 Subject: [PATCH] Make svg, jpeg and png images resizable in notebook. --- diff --git a/IPython/frontend/html/notebook/static/js/outputarea.js b/IPython/frontend/html/notebook/static/js/outputarea.js index b769a08..5180747 100644 --- a/IPython/frontend/html/notebook/static/js/outputarea.js +++ b/IPython/frontend/html/notebook/static/js/outputarea.js @@ -275,21 +275,35 @@ var IPython = (function (IPython) { OutputArea.prototype.append_svg = function (svg, element) { var toinsert = $("
").addClass("box-flex1 output_subarea output_svg"); - toinsert.append(svg); + var img = $('
'); + img.append(svg); + var h = img.find('svg').attr('height'); + var w = img.find('svg').attr('width'); + img.width(w).height(h); + img.resizable({'aspectRatio': true}); + toinsert.append(img); element.append(toinsert); }; OutputArea.prototype.append_png = function (png, element) { var toinsert = $("
").addClass("box-flex1 output_subarea output_png"); - toinsert.append($("").attr('src','data:image/png;base64,'+png)); + var img = $("").attr('src','data:image/png;base64,'+png); + img.load(function () { + $(this).resizable({'aspectRatio': true}) + }); + toinsert.append(img); element.append(toinsert); }; OutputArea.prototype.append_jpeg = function (jpeg, element) { var toinsert = $("
").addClass("box-flex1 output_subarea output_jpeg"); - toinsert.append($("").attr('src','data:image/jpeg;base64,'+jpeg)); + var img = $("").attr('src','data:image/jpeg;base64,'+jpeg); + img.load(function () { + $(this).resizable({'aspectRatio': true}) + }); + toinsert.append(img); element.append(toinsert); };