TG Telegram Group & Channel
GeekTips | United States America (US)
Create: Update:

So here's my script using python pixelate

pip install pixelate
https://github.com/useless-tools/pixelate

There is an advanced pixelate app but don't think I need that one just a simple one
https://github.com/sedthh/pyxelate

If you just wanna convert a few images yourself try this free online one
https://giventofly.github.io/pixelit/

also convert (image magick) doesn't work well at all for svg to png so rsvg-convert to the rescue which can be installed by
sudo apt install librsvg2-bin

I was even cropping the images to center them but found it's not always good to do.
parallel -j2 --ungroup mogrify -fuzz 15% -trim +repage -resize 1024x1024 {} {} ::: *.png

Also there's an online editor where you can draw in your own pixellated svg.
https://fffuel.co/pppixelate/
but I got over 30,000 static svgs to batch convert so it's not an option

I did learn that vtracer handles png alpha channels just fine on the command line but not on the GUI web app which kinda threw me for a loop. Cuz if you use the webapp for testing you'd think the new pixellated pngs will produce svgs with black backgrounds.

mkdir svg2png pixelpng pixelsvg ; st=$SECONDS && for i in *.svg; do rsvg-convert -w 1024 -h 1024 "$i" -o svg2png/"${i%svg}png"; done && cd svg2png && for f in *.png ; do pixelate --input="$f" --output=../pixelpng/"$f" --pixel-size 30 ; done && cd ../pixelpng && for f in *.png ; do vtracer-linux -i "$f" -o ../pixelsvg/"${f%.png}.pix.svg" -f 2 -p 7 -g 16 -m polygon; done && cd .. && rm pixelpng/* svg2png/* && rmdir pixelpng svg2png && cd pixelsvg && printf -v svgs $(ls | wc -l) && mkdir output ; mv *.svg output/ ; printf -v aa $(du -sh output/) && svgo --config ~/Documents/appimages/svgo.config.js -f ./output/ -o . && rm output/*.svg && printf -v bb $(du -sh) && for f in *.svg; do sed -i -r 's|([0-9]+\.[0-9]{1})[0-9]+|\1|g' "$f" ; done && rmdir output/ && mv *.svg .. && cd .. && rmdir pixelsvg && e=$((SECONDS-st)) && printf "\nSVG Pixelate and Optimization took $e seconds\n\nsvg org filesize: $aa\nsvgo svg filesize: $bb\nsed svg filesize: $(du -sh)\n\n# of original svgs: $svgs\n# of optimized svgs: $(ls | wc -l)\n"

So here's my script using python pixelate
pip install pixelate
https://github.com/useless-tools/pixelate

There is an advanced pixelate app but don't think I need that one just a simple one
https://github.com/sedthh/pyxelate

If you just wanna convert a few images yourself try this free online one
https://giventofly.github.io/pixelit/

also convert (image magick) doesn't work well at all for svg to png so rsvg-convert to the rescue which can be installed by
sudo apt install librsvg2-bin

I was even cropping the images to center them but found it's not always good to do.
parallel -j2 --ungroup mogrify -fuzz 15% -trim +repage -resize 1024x1024 {} {} ::: *.png

Also there's an online editor where you can draw in your own pixellated svg.
https://fffuel.co/pppixelate/
but I got over 30,000 static svgs to batch convert so it's not an option

I did learn that vtracer handles png alpha channels just fine on the command line but not on the GUI web app which kinda threw me for a loop. Cuz if you use the webapp for testing you'd think the new pixellated pngs will produce svgs with black backgrounds.

mkdir svg2png pixelpng pixelsvg ; st=$SECONDS && for i in *.svg; do rsvg-convert -w 1024 -h 1024 "$i" -o svg2png/"${i%svg}png"; done && cd svg2png && for f in *.png ; do pixelate --input="$f" --output=../pixelpng/"$f" --pixel-size 30 ; done && cd ../pixelpng && for f in *.png ; do vtracer-linux -i "$f" -o ../pixelsvg/"${f%.png}.pix.svg" -f 2 -p 7 -g 16 -m polygon; done && cd .. && rm pixelpng/* svg2png/* && rmdir pixelpng svg2png && cd pixelsvg && printf -v svgs $(ls | wc -l) && mkdir output ; mv *.svg output/ ; printf -v aa $(du -sh output/) && svgo --config ~/Documents/appimages/svgo.config.js -f ./output/ -o . && rm output/*.svg && printf -v bb $(du -sh) && for f in *.svg; do sed -i -r 's|([0-9]+\.[0-9]{1})[0-9]+|\1|g' "$f" ; done && rmdir output/ && mv *.svg .. && cd .. && rmdir pixelsvg && e=$((SECONDS-st)) && printf "\nSVG Pixelate and Optimization took $e seconds\n\nsvg org filesize: $aa\nsvgo svg filesize: $bb\nsed svg filesize: $(du -sh)\n\n# of original svgs: $svgs\n# of optimized svgs: $(ls | wc -l)\n"


>>Click here to continue<<

GeekTips






Share with your best friend
VIEW MORE

United States America Popular Telegram Group (US)