Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Unified Diff: ui/file_manager/gallery/js/image_editor/commands.js

Issue 2299493002: Add an ability for resize in gallery. (Closed)
Patch Set: Add an ability for resize in gallery. Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/file_manager/gallery/js/image_editor/commands.js
diff --git a/ui/file_manager/gallery/js/image_editor/commands.js b/ui/file_manager/gallery/js/image_editor/commands.js
index a63801b2c37b8a207a0a907ecd7e6c34583ecfe3..9f7e6038ce9571290ef2e0685ffbc7b9a472a625 100644
--- a/ui/file_manager/gallery/js/image_editor/commands.js
+++ b/ui/file_manager/gallery/js/image_editor/commands.js
@@ -450,3 +450,34 @@ Command.Filter.prototype.execute = function(
filter.applyByStrips(result, srcImage, this.filter_,
uiContext.imageView ? onProgressVisible : onProgressInvisible);
};
+
+/**
+ * Resize Command
+ * @param {number} inputWidth width user input
+ * @param {number} inputHeight height user input
+ * @constructor
+ * @extends {Command}
+ * @struct
+ */
+Command.Resize = function(inputWidth, inputHeight) {
+ Command.call(this, 'resize(x:' + inputWidth + ',y:' + inputHeight + ')');
+ this.newWidth_ = inputWidth;
+ this.newHeight_ = inputHeight;
+};
+
+Command.Resize.prototype = {__proto__: Command.prototype};
+
+/** @override */
+Command.Resize.prototype.execute = function(
+ document, srcImage, callback, uiContext) {
+ var result = this.createCanvas_(
+ document, srcImage, this.newWidth_, this.newHeight_);
+
+ var scaleX = this.newWidth_ / srcImage.width;
+ var scaleY = this.newHeight_ / srcImage.height;
+ ImageUtil.drawImageTransformed(result, srcImage, scaleX, scaleY, 0);
+
+ if(uiContext.imageView)
+ uiContext.imageView.replace(result);
+ callback(result);
+};

Powered by Google App Engine
This is Rietveld 408576698