/
githubmirror
/
nativefier
Обзор
Документация
Войти
/
githubmirror
/
nativefier
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
icon-scripts/convertToIcns
56 строк
1 KB
Ronan Jouchet
Fix icon conversion scripts broken on recent macOS (fix #1277)
23 ноя 2021, 00:18
23 ноя 2021, 00:18
4405b5d
Код
Авторство
О чём код?
#!/usr/bin/env bash ### USAGE # ./convertToIcns <input png> <outp icns> # Example # ./convertToIcns ~/sample.png ~/Desktop/converted.icns # exit the shell script on error immediately set -e # Exec Paths HAVE_IMAGEMAGICK= HAVE_ICONUTIL= HAVE_SIPS= HAVE_GRAPHICSMAGICK= type convert &>/dev/null && HAVE_IMAGEMAGICK=true type iconutil &>/dev/null && HAVE_ICONUTIL=true type sips &>/dev/null && HAVE_SIPS=true type gm &>/dev/null && gm version | grep GraphicsMagick &>/dev/null && HAVE_GRAPHICSMAGICK=true [[ -z "$HAVE_ICONUTIL" ]] && { echo >&2 "Cannot find required iconutil executable"; exit 1; } [[ -z "$HAVE_IMAGEMAGICK" && -z "$HAVE_SIPS" && -z "$HAVE_GRAPHICSMAGICK" ]] && { echo >&2 "Cannot find required image converter, please install sips, imagemagick or graphicsmagick"; exit 1; } # Parameters SOURCE="$1" DEST="$2" # Check source and destination arguments if [ -z "${SOURCE}" ]; then echo "No source image specified" exit 1 fi if [ -z "${DEST}" ]; then echo "No destination specified" exit 1 fi TEMP_DIR="$(mktemp -d -t nativefier-icns-XXXXXX)" ICONSET="${TEMP_DIR}/converted.iconset" function cleanUp() { rm -rf "${TEMP_DIR}" } trap cleanUp EXIT "${BASH_SOURCE%/*}/convertToIconset" "${SOURCE}" "${ICONSET}" # Create an icns file lefrom the iconset iconutil -c icns "${ICONSET}" -o "${DEST}" trap - EXIT cleanUp