mirror of
https://github.com/finos/SymphonyElectron.git
synced 2025-02-25 18:55:29 -06:00
ELECTRON-1161: converting from png to jpg using jimp (#615)
This commit is contained in:
parent
b55da7be65
commit
b591a1fe56
@ -4,6 +4,7 @@ const electron = require('electron');
|
|||||||
const app = electron.app;
|
const app = electron.app;
|
||||||
const childProcess = require('child_process');
|
const childProcess = require('child_process');
|
||||||
const fs = require('fs');
|
const fs = require('fs');
|
||||||
|
const Jimp = require('jimp');
|
||||||
const os = require('os');
|
const os = require('os');
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
|
|
||||||
@ -143,12 +144,20 @@ function readResult(outputFileName, resolve, reject, childProcessErr) {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// convert binary data to base64 encoded string
|
// convert binary data to base64 encoded string
|
||||||
let output = Buffer.from(data).toString('base64');
|
Jimp.read(outputFileName, (error, image) => {
|
||||||
const resultOutput = {
|
if (error) throw error;
|
||||||
type: isWindowsOS ? 'image/png;base64' : 'image/jpg;base64',
|
image.quality(100)
|
||||||
data: output
|
.getBufferAsync(Jimp.MIME_JPEG).then(src => {
|
||||||
};
|
const value = src.toString('base64');
|
||||||
resolve(resultOutput);
|
const resultOutput = {
|
||||||
|
type: 'image/jpg;base64',
|
||||||
|
data: value,
|
||||||
|
};
|
||||||
|
resolve(resultOutput);
|
||||||
|
}).catch((e) => {
|
||||||
|
log.send(logLevels.ERROR, e);
|
||||||
|
});
|
||||||
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
reject(createError(error));
|
reject(createError(error));
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -118,6 +118,7 @@
|
|||||||
"electron-spellchecker": "git+https://github.com/symphonyoss/electron-spellchecker.git#v1.1.5",
|
"electron-spellchecker": "git+https://github.com/symphonyoss/electron-spellchecker.git#v1.1.5",
|
||||||
"ffi": "git+https://github.com/symphonyoss/node-ffi.git#v1.2.9",
|
"ffi": "git+https://github.com/symphonyoss/node-ffi.git#v1.2.9",
|
||||||
"filesize": "3.6.1",
|
"filesize": "3.6.1",
|
||||||
|
"jimp": "0.6.0",
|
||||||
"keymirror": "0.1.1",
|
"keymirror": "0.1.1",
|
||||||
"lodash.difference": "4.5.0",
|
"lodash.difference": "4.5.0",
|
||||||
"lodash.isequal": "4.5.0",
|
"lodash.isequal": "4.5.0",
|
||||||
|
2
tests/fixtures/snippet/snippet-base64.js
vendored
2
tests/fixtures/snippet/snippet-base64.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user