|
@@ -1,4 +1,4 @@
|
|
|
-var debug = require('debug')('ylt:screenshotHandler');
|
|
|
+var debug = require('debug')('ylt:screenshotHandlerAgent');
|
|
|
var Jimp = require('jimp');
|
|
|
var Q = require('q');
|
|
|
var fs = require('fs');
|
|
@@ -7,21 +7,15 @@ var path = require('path');
|
|
|
|
|
|
var screenshotHandler = function() {
|
|
|
|
|
|
- var tmpFolderPath = 'tmp';
|
|
|
- var tmpFolderFullPath = path.join(__dirname, '..', tmpFolderPath);
|
|
|
- var tmpFileName = 'temp-screenshot.png';
|
|
|
- var tmpFileFullPath = path.join(tmpFolderFullPath, tmpFileName);
|
|
|
-
|
|
|
-
|
|
|
- this.findAndOptimizeScreenshot = function(width) {
|
|
|
+ this.findAndOptimizeScreenshot = function(tmpScreenshotPath, width) {
|
|
|
var that = this;
|
|
|
|
|
|
debug('Starting screenshot transformation');
|
|
|
|
|
|
- return this.openImage(tmpFileFullPath)
|
|
|
+ return this.openImage(tmpScreenshotPath)
|
|
|
|
|
|
.then(function(image) {
|
|
|
- that.deleteTmpFile(tmpFileFullPath);
|
|
|
+ that.deleteTmpFile(tmpScreenshotPath);
|
|
|
return that.resizeImage(image, width);
|
|
|
})
|
|
|
|
|
@@ -109,10 +103,6 @@ var screenshotHandler = function() {
|
|
|
|
|
|
return deferred.promise;
|
|
|
};
|
|
|
-
|
|
|
- this.getTmpFileRelativePath = function() {
|
|
|
- return tmpFolderPath + '/' + tmpFileName;
|
|
|
- };
|
|
|
};
|
|
|
|
|
|
module.exports = new screenshotHandler();
|