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 childProcess = require('child_process');
|
||||
const fs = require('fs');
|
||||
const Jimp = require('jimp');
|
||||
const os = require('os');
|
||||
const path = require('path');
|
||||
|
||||
@ -143,12 +144,20 @@ function readResult(outputFileName, resolve, reject, childProcessErr) {
|
||||
|
||||
try {
|
||||
// convert binary data to base64 encoded string
|
||||
let output = Buffer.from(data).toString('base64');
|
||||
const resultOutput = {
|
||||
type: isWindowsOS ? 'image/png;base64' : 'image/jpg;base64',
|
||||
data: output
|
||||
};
|
||||
resolve(resultOutput);
|
||||
Jimp.read(outputFileName, (error, image) => {
|
||||
if (error) throw error;
|
||||
image.quality(100)
|
||||
.getBufferAsync(Jimp.MIME_JPEG).then(src => {
|
||||
const value = src.toString('base64');
|
||||
const resultOutput = {
|
||||
type: 'image/jpg;base64',
|
||||
data: value,
|
||||
};
|
||||
resolve(resultOutput);
|
||||
}).catch((e) => {
|
||||
log.send(logLevels.ERROR, e);
|
||||
});
|
||||
});
|
||||
} catch (error) {
|
||||
reject(createError(error));
|
||||
} finally {
|
||||
|
@ -118,6 +118,7 @@
|
||||
"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",
|
||||
"filesize": "3.6.1",
|
||||
"jimp": "0.6.0",
|
||||
"keymirror": "0.1.1",
|
||||
"lodash.difference": "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