mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-12-22 18:18:55 +00:00
cbb4380583
Co-authored-by: Ronan Jouchet <ronan@jouchet.fr>
40 lines
750 B
Bash
Executable File
40 lines
750 B
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
# USAGE
|
|
|
|
# ./convertToIco <input png or ico> <outfilename>.ico
|
|
# Example
|
|
# ./convertToPng ~/sample.png ~/converted.ico
|
|
|
|
set -e
|
|
|
|
CONVERT=
|
|
|
|
type gm &>/dev/null && gm version | grep GraphicsMagick &>/dev/null && CONVERT="gm convert"
|
|
type convert &>/dev/null && CONVERT="convert"
|
|
|
|
[[ -z "$CONVERT" ]] && { echo >&2 "Cannot find required ImageMagick Convert or GraphicsMagick executable"; exit 1; }
|
|
|
|
SOURCE=$1
|
|
DEST=$2
|
|
|
|
if [ -z "${SOURCE}" ]; then
|
|
echo "No source image specified"
|
|
exit 1
|
|
fi
|
|
|
|
if [ -z "${DEST}" ]; then
|
|
echo "No destination specified"
|
|
exit 1
|
|
fi
|
|
|
|
NAME=$(basename "${SOURCE}")
|
|
EXT="${NAME##*.}"
|
|
|
|
if [ "${EXT}" == "ico" ]; then
|
|
cp "${SOURCE}" "${DEST}"
|
|
exit 0
|
|
fi
|
|
|
|
$CONVERT "${SOURCE}" -resize 256x256 "${DEST}"
|