Skip to content

Commit 4c55801

Browse files
Feat/svg converter (#6)
* feat: generate png images from svg on pull request to main * Generate PNGs --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
1 parent cf07ff2 commit 4c55801

17 files changed

+54
-0
lines changed

.github/workflows/generate-png.yml

+54
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Generate PNGs
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- master
7+
8+
jobs:
9+
convert-svg-to-png:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- name: Checkout Repository
14+
uses: actions/checkout@v3
15+
16+
- name: Install Inkscape
17+
run: |
18+
sudo apt install inkscape
19+
20+
- name: Install Pngquant
21+
run: |
22+
sudo apt install pngquant
23+
24+
- name: Convert SVGs to PNGs
25+
run: |
26+
total_files=$(find ./ -type f -name "*.svg" | wc -l)
27+
progress=0
28+
29+
find ./ -type f -name "*.svg" | while IFS= read -r file; do
30+
progress=$((progress + 1))
31+
percentage=$((progress * 100 / total_files))
32+
filled=$((percentage / 2))
33+
unfilled=$((50 - filled))
34+
35+
printf "\rProgress: [%${filled}s%${unfilled}s] %d%%" "$(printf '#%.0s' $(seq 1 $filled))" "$(printf ' %.0s' $(seq 1 $unfilled))" "$percentage"
36+
png_file="${file%.svg} 4k"
37+
# convert -background none -density 700 "$file" -quality 100 -resize 4000 "$png_file"
38+
inkscape "$file" --export-background-opacity=0 -h 4000 -o "$png_file".temp.png
39+
pngquant -f --quality 100 "$png_file".temp.png --output "$png_file".png
40+
rm "$png_file".temp.png
41+
done
42+
echo
43+
44+
- name: Commit and Push Converted PNGs
45+
env:
46+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
47+
run: |
48+
git config --global user.name "github-actions[bot]"
49+
git config --global user.email "github-actions[bot]@users.noreply.github.com"
50+
git fetch origin "${GITHUB_HEAD_REF}"
51+
git checkout "${GITHUB_HEAD_REF}"
52+
git add .
53+
git commit -m "Generate PNGs"
54+
git push origin "${GITHUB_HEAD_REF}"

Logotyper IN/IN Logo 4k.png

-112 KB
Loading
-213 KB
Binary file not shown.
-92.2 KB
Loading
133 KB
Loading

namnder/idrott/Idrottsnämnden 4k.png

-416 KB
Binary file not shown.
239 KB
Loading

namnder/jml/JML Logo 4k.png

-109 KB
Loading
Loading

namnder/mottagningen/Doq Logo 4k.png

-85.9 KB
Loading

namnder/mottagningen/MUX Logo 4k.png

-38.2 KB
Loading
-122 KB
Loading
Loading

namnder/smn/SMN Logo 4k.png

-117 KB
Loading
-99 KB
Loading

overaller/in ovveprint vit 4k.png

169 KB
Loading

overaller/in ovvetryck vit.png

-55.8 KB
Binary file not shown.

0 commit comments

Comments
 (0)