Adds compression of frontend logo images

parent d136f216
Pipeline #21897 passed with stages
in 9 minutes and 39 seconds
......@@ -69,7 +69,10 @@ generate_assets:
- apt-get -y install --allow-unauthenticated google-chrome-stable imagemagick libpng-dev zlib1g-dev clang
- export CHROME_BIN=`whereis google-chrome | cut -d " " -f 2`
- npm install
- cd dist/browser/assets/jobs
- cd dist
- node server &
- sleep 15s
- cd browser/assets/jobs
- node --experimental-modules GenerateImages.mjs --command=generateLogoImages
- node --experimental-modules GenerateImages.mjs --command=generateFrontendPreview --host=http://localhost:4000
- node GenerateMetaNodes.js --command=generateLinkImages --baseUrl=https://staging.arsnova.click
......
......@@ -62,7 +62,6 @@
"@techiediaries/ngx-qrcode": "0.0.5",
"angulartics2": "^7.2.1",
"bootstrap": "^4.1.3",
"chrome-launcher": "^0.10.5",
"classlist.js": "^1.1.20150312",
"cors": "^2.8.5",
"highlight.js": "^9.13.1",
......@@ -86,6 +85,7 @@
"@types/node": "^10.12.10",
"@types/webpack": "~4.4.20",
"arsnova-click-v2-types": "git+https://git.thm.de/arsnova/arsnova-click-v2-types.git",
"chrome-launcher": "^0.10.5",
"chrome-remote-interface": "^0.27.0",
"codelyzer": "^4.5.0",
"http-server": "^0.11.1",
......
......@@ -93,8 +93,7 @@ async function runNavigation({Page, DOM, Emulation, client, url, imgPath}) {
}
const screenshot = await Page.captureScreenshot({format});
const buffer = new Buffer(screenshot.data, 'base64');
file.writeFile(`${imgPath}`, buffer, 'base64', function (err) {
file.writeFile(`${imgPath}`, screenshot.data, function (err) {
if (err) {
console.error(err);
} else {
......
......@@ -8,6 +8,8 @@ import process from 'process';
import child_process from 'child_process';
import minimist from 'minimist';
import {default as chromeLauncher} from 'chrome-launcher';
import {default as imagemin} from 'imagemin';
import {default as imageminPngquant} from 'imagemin-pngquant';
const argv = minimist(process.argv.slice(2));
......@@ -94,7 +96,7 @@ class GenerateImages {
console.log('chrome stuff', CHROME_BIN, themePreviewEndpoint, params);
// const chromeInstance = child_process.spawnSync(CHROME_BIN, flags);
const chromeDriver = child_process.spawn(`node`, [
path.join('ChromeDriver.js'), `--urls=${JSON.stringify(params)}`
path.join('ChromeDriver.js'), `--urls=${JSON.stringify(params)} --full --delay=100`
]);
chromeDriver.stdout.on('data', (data) => {
......@@ -135,13 +137,18 @@ class GenerateImages {
`<svg><rect x="0" y="0" width="${size.width}" height="${size.height}" rx="${size.roundX}" ry="${size.roundY}"/></svg>`
);
const minifiedBuffer = await sharp(source)
const buffer = await sharp(source)
.resize(size.width, size.height)
.overlayWith(roundedCorners, {cutout: true})
.flatten({background: theme})
.sharpen()
.png()
.toBuffer();
const minifiedBuffer = await imagemin.buffer(buffer, {
plugins: [imageminPngquant({quality: '65-80'})]
});
fs.writeFileSync(targetLogo, minifiedBuffer, 'binary');
console.log(`Writing file '${targetLogo}'`);
console.log(`Icon with size of ${derivate}px generated for theme ${themeName}`);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment