Update 20 euro cent coins edge

This commit is contained in:
2023-10-09 19:34:43 +01:00
parent 1391ae93a5
commit ac2c4a3246
4 changed files with 69 additions and 49 deletions

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -24,6 +24,16 @@ const asyncSpawn = (command: string, args: string[]) => {
});
};
const getEdgeRepeatNumber = (shape?: string) => {
switch(shape?.toLowerCase?.()) {
case 'spanish flower':
return 7;
default:
return 4;
}
}
const getPreviousResult = async (id: number) => {
try {
return await readFile(path.join('./public/photos/joined', `${id}.jpg`));
@@ -40,6 +50,7 @@ const generateImage = async (id: number) => {
}
const coin = await getType(id);
const edgeRepeatNumber = getEdgeRepeatNumber(coin?.shape)
if (!coin) {
return;
@@ -55,9 +66,9 @@ const generateImage = async (id: number) => {
} else {
await asyncSpawn('convert', [
'-size',
'512x64',
'256x256!',
`xc:${coin.color}`,
path.join('./public/photos/joined', `${id}-edge.jpg`)
path.join('./public/photos/joined', `${id}-obverse.jpg`)
]);
}
@@ -72,9 +83,9 @@ const generateImage = async (id: number) => {
} else {
await asyncSpawn('convert', [
'-size',
'512x64',
'256x256!',
`xc:${coin.color}`,
path.join('./public/photos/joined', `${id}-edge.jpg`)
path.join('./public/photos/joined', `${id}-reverse.jpg`)
]);
}
@@ -82,13 +93,13 @@ const generateImage = async (id: number) => {
await asyncSpawn('convert', [
path.join('./public', coin.edge.picture),
'-resize',
'512x64!',
`512x${256/edgeRepeatNumber}!`,
path.join('./public/photos/joined', `${id}-edge.jpg`)
]);
} else {
await asyncSpawn('convert', [
'-size',
'512x64',
`512x${256/edgeRepeatNumber}!`,
`xc:${coin.color}`,
path.join('./public/photos/joined', `${id}-edge.jpg`)
]);
@@ -101,7 +112,7 @@ const generateImage = async (id: number) => {
path.join('./public/photos/joined', `${id}.jpg`)
]);
for (let index = 0; index < 4; index++) {
for (let index = 0; index < edgeRepeatNumber; index++) {
await asyncSpawn('convert', [
path.join('./public/photos/joined', `${id}.jpg`),
path.join('./public/photos/joined', `${id}-edge.jpg`),