Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various shell scripts improvements, switch to oxipng #474

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion scripts/xmb-convert.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/usr/bin/env bash

# MonoChrome SVG to PNG Converter
#
Expand All @@ -17,6 +17,20 @@
# ./convert.sh monochrome battery-full
# ./convert.sh flatui DOS

exitFlag=0
checkCommand() {
if ! command -v "${1}" >/dev/null; then
echo "${1} not installed!"
exitFlag=1
fi
}
checkCommand 'inkscape'
checkCommand 'oxipng'
if [[ ${exitFlag} -eq 1 ]]; then
exit 1
fi

cd -- "$(cd -- "$(dirname -- "$0")" && pwd -P)"

inkscape -z -e "$1/png/$2.png" -w 256 -h 256 "../src/xmb/$1/$2.svg"
oxipng --quiet --zopfli --opt max --strip all "$1/png/$2.png"
26 changes: 20 additions & 6 deletions src/sounds/convert_ogg.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
#!/usr/bin/env bash

exitFlag=0
checkCommand() {
if ! command -v "${1}" >/dev/null; then
echo "${1} not installed!"
exitFlag=1
fi
}
checkCommand 'ffmpeg'
if [[ ${exitFlag} -eq 1 ]]; then
exit 1
fi

# Script to convert to OGG, rename to lowercase and copy chosen sounds
# requires ffmpeg and libvorbis/libogg
SOUNDS="OK.wav CANCEL.wav BGM.wav UP.wav DOWN.wav LAUNCH.wav NOTICE.wav NOTICE_BACK.wav"

mkdir -p ../../sounds
for src in $SOUNDS; do
export dest=`echo $src | sed "s/.wav/.ogg/"`
export dest=`echo "$dest" | tr '[:upper:]' '[:lower:]'`
echo "$src -> $dest"
ffmpeg -i $src -acodec libvorbis ../../sounds/$dest
export dest=$(echo $src | sed "s/.wav/.ogg/")
export dest=$(echo "$dest" | tr '[:upper:]' '[:lower:]')
echo "$src -> $dest"

ffmpeg -i $src -acodec libvorbis ../../sounds/$dest
done

cp Licence.txt ../../sounds/Licence.txt
17 changes: 16 additions & 1 deletion src/xmb/convert_xmb_assets.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
#!/usr/bin/env bash

exitFlag=0
checkCommand() {
if ! command -v "${1}" >/dev/null; then
echo "${1} not installed!"
exitFlag=1
fi
}
checkCommand 'convert'
checkCommand 'oxipng'
if [[ ${exitFlag} -eq 1 ]]; then
exit 1
fi

convert_xmb_assets()
{
SRC_DIR="$1"
Expand Down Expand Up @@ -50,7 +65,7 @@ convert_xmb_assets()
else
convert -background 'rgb(255,255,255)' -alpha Background "$SRC_FILE" -resize $SCALE_FACTOR "$DST_FILE"
fi
optipng -quiet -o7 -strip all "$DST_FILE"
oxipng --quiet --zopfli --opt max --strip all "$DST_FILE"

fi
done
Expand Down
21 changes: 18 additions & 3 deletions src/xmb/monochrome/export.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,28 @@
#!/usr/bin/env bash

exitFlag=0
checkCommand() {
if ! command -v "${1}" >/dev/null; then
echo "${1} not installed!"
exitFlag=1
fi
}
checkCommand 'inkscape'
checkCommand 'magick'
checkCommand 'oxipng'
if [[ ${exitFlag} -eq 1 ]]; then
exit 1
fi

for src in *.svg; do
echo $src;
export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../xmb/monochrome/png
inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../xmb/monochrome/png/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../xmb/monochrome/png/$dest"
optipng -o7 -strip all "../../../xmb/monochrome/png/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../xmb/monochrome/png/$dest"
#rsvg-convert -b none -w 256 -h 256 "$src" -o "../png/$dest"
#convert -density 360 -background none "$src" "../png/$dest"
#convert "../png/$dest" -write mpr:temp -background black -alpha Remove mpr:temp -compose Copy_Opacity -composite "../png/$dest"
#python2 ../../NPMApng2PMApng.py "../png/$dest" "../png/$dest"
done

46 changes: 31 additions & 15 deletions src/xmb/monochrome/export_ozone.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#!/usr/bin/env bash

exitFlag=0
checkCommand() {
if ! command -v "${1}" >/dev/null; then
echo "${1} not installed!"
exitFlag=1
fi
}
checkCommand 'inkscape'
checkCommand 'magick'
checkCommand 'oxipng'
if [[ ${exitFlag} -eq 1 ]]; then
exit 1
fi

for src in *.svg
do
fletter="$(echo $src | head -c 1)"
Expand All @@ -21,49 +37,49 @@ do

echo "Exporting $src ($size x $size)"

export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../ozone/png/icons
inkscape -z -C -w $size -h $size -f "$src" -e "../../../ozone/png/icons/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest"
optipng -o7 -strip all "../../../ozone/png/icons/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest"
done

# Override some icons (different size and color)
src="clock.svg"
export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../ozone/png/icons
inkscape -z -C -w 92 -h 92 -f "$src" -e "../../../ozone/png/icons/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest"
optipng -o7 -strip all "../../../ozone/png/icons/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest"

for src in battery-*.svg; do
export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../ozone/png/icons
inkscape -z -C -w 92 -h 92 -f "$src" -e "../../../ozone/png/icons/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest"
optipng -o7 -strip all "../../../ozone/png/icons/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest"
done

src="dialog-slice.svg"
export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../ozone/png/icons
inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest"
optipng -o7 -strip all "../../../ozone/png/icons/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest"

src="key-hover.svg"
export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../ozone/png/icons
inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest"
optipng -o7 -strip all "../../../ozone/png/icons/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest"

src="key.svg"
export dest=`echo $src | sed "s/.svg/.png/"`
export dest=$(echo $src | sed "s/.svg/.png/")
mkdir -p ../../../ozone/png/icons
inkscape -z -C -w 256 -h 256 -f "$src" -e "../../../ozone/png/icons/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/icons/$dest"
optipng -o7 -strip all "../../../ozone/png/icons/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/icons/$dest"

# Export auxiliary sidebar icons
SIDEBAR_SRC[0]="add.svg" # add.png
Expand Down Expand Up @@ -146,7 +162,7 @@ do
fi

magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/sidebar/$dest"
optipng -o7 -strip all "../../../ozone/png/sidebar/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/sidebar/$dest"

done

Expand All @@ -158,7 +174,7 @@ dest="netplay.png"
magick convert "$src" xc:"#ffffff" -channel RGB -clut "../../../ozone/png/sidebar/$dest"
magick mogrify -resize 64x64 "../../../ozone/png/sidebar/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/sidebar/$dest"
optipng -o7 -strip all "../../../ozone/png/sidebar/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/sidebar/$dest"

# Export main RetroArch icon
src="menu_quickmenu.svg"
Expand All @@ -170,4 +186,4 @@ border_size=11
inkscape -z -C -w $size -h $size -f "$src" -e "../../../ozone/png/$dest"
magick mogrify -shave $border_size "../../../ozone/png/$dest"
magick mogrify -background 'rgb(255,255,255)' -alpha Background "../../../ozone/png/$dest"
optipng -o7 -strip all "../../../ozone/png/$dest"
oxipng --quiet --zopfli --opt max --strip all "../../../ozone/png/$dest"