Add detection for svgs which actually contain pngs, convert png into proper svg
This commit is contained in:
parent
278fce8726
commit
dd63ed7ab0
5 changed files with 981 additions and 2482 deletions
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 2.7 KiB |
File diff suppressed because it is too large
Load diff
Before Width: | Height: | Size: 141 KiB After Width: | Height: | Size: 50 KiB |
File diff suppressed because one or more lines are too long
Before Width: | Height: | Size: 33 KiB After Width: | Height: | Size: 7.4 KiB |
|
@ -96,6 +96,26 @@ class LayerOverviewUtils {
|
||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
checkAllSvgs(){
|
||||||
|
const allSvgs = ScriptUtils.readDirRecSync("./assets")
|
||||||
|
.filter(path => path.endsWith(".svg"))
|
||||||
|
.filter(path => !path.startsWith("./assets/generated"))
|
||||||
|
let errCount = 0;
|
||||||
|
for (const path of allSvgs) {
|
||||||
|
const contents = readFileSync(path, "UTF8")
|
||||||
|
if (contents.indexOf("data:image/png;") < 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
console.warn("The SVG at " + path + " is a fake SVG: it contains PNG data!")
|
||||||
|
errCount++;
|
||||||
|
if(path.startsWith("./assets/svg")){
|
||||||
|
throw "A core SVG is actually a PNG. Don't do this!"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("There are "+errCount+" fake svgs")
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
main(_: string[]) {
|
main(_: string[]) {
|
||||||
|
|
||||||
const licensePaths = new Set<string>()
|
const licensePaths = new Set<string>()
|
||||||
|
@ -126,8 +146,9 @@ class LayerOverviewUtils {
|
||||||
const rendering = (<PointRenderingConfigJson>protolayer.mapRendering[0])
|
const rendering = (<PointRenderingConfigJson>protolayer.mapRendering[0])
|
||||||
rendering.icon["mappings"] = iconsPerTheme
|
rendering.icon["mappings"] = iconsPerTheme
|
||||||
writeFileSync('./assets/themes/mapcomplete-changes/mapcomplete-changes.json', JSON.stringify(proto, null, " "))
|
writeFileSync('./assets/themes/mapcomplete-changes/mapcomplete-changes.json', JSON.stringify(proto, null, " "))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.checkAllSvgs()
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildLayerIndex(knownImagePaths: Set<string>): Map<string, LayerConfigJson> {
|
private buildLayerIndex(knownImagePaths: Set<string>): Map<string, LayerConfigJson> {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import * as all_known_layouts from "../assets/generated/known_layers_and_themes.
|
||||||
import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson";
|
import {LayoutConfigJson} from "../Models/ThemeConfig/Json/LayoutConfigJson";
|
||||||
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
import LayoutConfig from "../Models/ThemeConfig/LayoutConfig";
|
||||||
import xml2js from 'xml2js';
|
import xml2js from 'xml2js';
|
||||||
|
import ScriptUtils from "./ScriptUtils";
|
||||||
|
|
||||||
const sharp = require('sharp');
|
const sharp = require('sharp');
|
||||||
const template = readFileSync("theme.html", "utf8");
|
const template = readFileSync("theme.html", "utf8");
|
||||||
|
@ -282,7 +283,6 @@ async function main(): Promise<void>{
|
||||||
const manif = JSON.stringify(manifObj, undefined, 2);
|
const manif = JSON.stringify(manifObj, undefined, 2);
|
||||||
writeFileSync("index.manifest", manif)
|
writeFileSync("index.manifest", manif)
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main().then(() => {
|
main().then(() => {
|
||||||
|
|
Loading…
Reference in a new issue