Skip to content

Commit

Permalink
fix image resizing
Browse files Browse the repository at this point in the history
  • Loading branch information
Ali Abid committed Aug 6, 2020
1 parent 2943492 commit b9718cd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
20 changes: 9 additions & 11 deletions build/lib/gradio/static/js/interfaces/input/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,15 @@ const image_input = {
image_data: null,
set_image_data: function(data, update_editor) {
let io = this;
resizeImage.call(this, data, 600, 600, function(image_data) {
io.image_data = image_data
io.target.find(".image_preview").attr('src', image_data);
if (update_editor) {
io.tui_editor.loadImageFromURL(io.image_data, 'input').then(function (sizeValue) {
io.tui_editor.clearUndoStack();
io.tui_editor.ui.activeMenuEvent();
io.tui_editor.ui.resizeEditor({ imageSize: sizeValue });
});
}
})
io.image_data = data
io.target.find(".image_preview").attr('src', data);
if (update_editor) {
io.tui_editor.loadImageFromURL(io.image_data, 'input').then(function (sizeValue) {
io.tui_editor.clearUndoStack();
io.tui_editor.ui.activeMenuEvent();
io.tui_editor.ui.resizeEditor({ imageSize: sizeValue });
});
}
},
load_preview_from_files: function(files) {
if (!files.length || !window.FileReader || !/^image/.test(files[0].type)) {
Expand Down
20 changes: 9 additions & 11 deletions gradio/static/js/interfaces/input/image.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,15 @@ const image_input = {
image_data: null,
set_image_data: function(data, update_editor) {
let io = this;
resizeImage.call(this, data, 600, 600, function(image_data) {
io.image_data = image_data
io.target.find(".image_preview").attr('src', image_data);
if (update_editor) {
io.tui_editor.loadImageFromURL(io.image_data, 'input').then(function (sizeValue) {
io.tui_editor.clearUndoStack();
io.tui_editor.ui.activeMenuEvent();
io.tui_editor.ui.resizeEditor({ imageSize: sizeValue });
});
}
})
io.image_data = data
io.target.find(".image_preview").attr('src', data);
if (update_editor) {
io.tui_editor.loadImageFromURL(io.image_data, 'input').then(function (sizeValue) {
io.tui_editor.clearUndoStack();
io.tui_editor.ui.activeMenuEvent();
io.tui_editor.ui.resizeEditor({ imageSize: sizeValue });
});
}
},
load_preview_from_files: function(files) {
if (!files.length || !window.FileReader || !/^image/.test(files[0].type)) {
Expand Down

0 comments on commit b9718cd

Please sign in to comment.