diff options
author | techknowlogick <techknowlogick@gitea.io> | 2020-12-17 16:33:53 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-12-17 16:33:53 -0500 |
commit | f8a668ab0c098476a47b9d96fb061fa31fec78ef (patch) | |
tree | df5dd03a96e729153d5ad05137b2eb49e58ab7b1 /build/generate-images.js | |
parent | e4567d428575405eda834bb49330e2e8b300642b (diff) | |
download | gitea-f8a668ab0c098476a47b9d96fb061fa31fec78ef.tar.gz gitea-f8a668ab0c098476a47b9d96fb061fa31fec78ef.zip |
Clean up SVG (#13680)
* Clean up SVG
* update per feedback
* fix css style
* Delete gitea.png
* no new line at end of file
* fix newline?
Co-authored-by: 6543 <6543@obermui.de>
Diffstat (limited to 'build/generate-images.js')
-rwxr-xr-x | build/generate-images.js | 21 |
1 files changed, 2 insertions, 19 deletions
diff --git a/build/generate-images.js b/build/generate-images.js index 9b7b820172..c7f58f61d0 100755 --- a/build/generate-images.js +++ b/build/generate-images.js @@ -3,7 +3,6 @@ const imageminZopfli = require('imagemin-zopfli'); const {fabric} = require('fabric'); -const {DOMParser, XMLSerializer} = require('xmldom'); const {readFile, writeFile} = require('fs').promises; const {resolve} = require('path'); const Svgo = require('svgo'); @@ -40,23 +39,7 @@ async function generateSvgFavicon(svg, outputFile) { await writeFile(outputFile, data); } -async function generate(svg, outputFile, {size, bg, removeDetail} = {}) { - const parser = new DOMParser(); - const serializer = new XMLSerializer(); - const document = parser.parseFromString(svg); - - if (removeDetail) { - for (const el of Array.from(document.getElementsByTagName('g') || [])) { - for (const attribute of Array.from(el.attributes || [])) { - if (attribute.name === 'class' && attribute.value === 'detail-remove') { - el.parentNode.removeChild(el); - } - } - } - } - - svg = serializer.serializeToString(document); - +async function generate(svg, outputFile, {size, bg}) { const {objects, options} = await loadSvg(svg); const canvas = new fabric.Canvas(); canvas.setDimensions({width: size, height: size}); @@ -93,7 +76,7 @@ async function main() { await generate(svg, resolve(__dirname, '../public/img/gitea-192.png'), {size: 192}); await generate(svg, resolve(__dirname, '../public/img/gitea-sm.png'), {size: 120}); await generate(svg, resolve(__dirname, '../public/img/avatar_default.png'), {size: 200}); - await generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180, removeDetail: true}); + await generate(svg, resolve(__dirname, '../public/img/favicon.png'), {size: 180}); await generate(svg, resolve(__dirname, '../public/img/apple-touch-icon.png'), {size: 180, bg: true}); } |