Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minify Module Image Not Showing Fix #1422

Closed
wants to merge 5 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions src/modules/MinifyImage/Module.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module.exports = function MinifyImage(options, UI) {
var output;
var defaults = require('./../../util/getDefaults.js')(require('./info.json'));
if (!options.inBrowser) {
base64Img = require('base64-img');
imagemin = require('imagemin');
Expand Down Expand Up @@ -39,17 +40,18 @@ module.exports = function MinifyImage(options, UI) {
return blob;

}
var quality = options.quality || defaults.quality;
if (options.inBrowser) {
var Compressor = require('compressorjs');
var blob = dataURItoBlob(input.src);
new Compressor(blob, {
quality: options.quality || 0.5,
quality: quality,
success(result) {
var reader = new FileReader();
reader.readAsDataURL(result);
reader.onloadend = function () {
base64data = reader.result;
output(base64data, input.format);
output(result, base64data, input.format);
if (callback) callback();
return;
};
Expand All @@ -76,7 +78,7 @@ module.exports = function MinifyImage(options, UI) {
});
var destPath = __dirname + '/results/test.' + input.format;
var data = base64Img.base64Sync(destPath);
output(data, input.format);
output(destPath, data, input.format);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we do this in the browser? Why is it even required? Can't we just output the image? Was it used for debugging and was left out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used for command line interface.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But that part is handled by the sequencer core library code anyway.

if (callback) callback();
})();
}
Expand All @@ -94,4 +96,3 @@ module.exports = function MinifyImage(options, UI) {
};
};