2
2
mirror of https://github.com/Llewellynvdm/nativefier.git synced 2024-09-22 01:29:02 +00:00

Allow .ico to be changed into an .icns

Update shell script to support `.ico` files that contain sequential images
This commit is contained in:
Jia Hao 2016-03-08 23:58:38 +08:00
parent 3f6f632d51
commit f48ad3790b
2 changed files with 25 additions and 19 deletions

View File

@ -29,7 +29,7 @@ fi
SOURCE=$1 SOURCE=$1
DEST=$2 DEST=$2
# Get source image # Check source and destination arguments
if [ -z "${SOURCE}" ]; then if [ -z "${SOURCE}" ]; then
echo "No source image specified" echo "No source image specified"
exit 1 exit 1
@ -41,13 +41,23 @@ if [ -z "${DEST}" ]; then
fi fi
# File Infrastructure # File Infrastructure
NAME=$(basename "${SOURCE}") NAME=$(basename "${SOURCE}")
EXT="${NAME##*.}" EXT="${NAME##*.}"
BASE="${NAME%.*}" BASE="${NAME%.*}"
ICONSET="${BASE}.iconset" ICONSET="${BASE}.iconset"
mkdir "${ICONSET}"
# check if .ico is a sequence
IS_ICO_SET="$(identify ${SOURCE} | grep -e "\w\.ico\[0")"
if [ "${IS_ICO_SET}" ]; then
# extract the largest(?) image from the set
convert "${SOURCE}" "${ICONSET}/${BASE}.png"
SOURCE="${ICONSET}/${BASE}-0.png"
fi
# Debug Info # Debug Info
# echo "SOURCE: ${SOURCE}" # echo "SOURCE: ${SOURCE}"
# echo "NAME: $NAME" # echo "NAME: $NAME"
@ -71,7 +81,6 @@ ICONSET="${BASE}.iconset"
#fi #fi
# Resample image into iconset # Resample image into iconset
mkdir "${ICONSET}"
convert "${SOURCE}" -define png:big-depth=16 -define png:color-type=6 -sample 16x16 "${ICONSET}/icon_16x16.png" convert "${SOURCE}" -define png:big-depth=16 -define png:color-type=6 -sample 16x16 "${ICONSET}/icon_16x16.png"
convert "${SOURCE}" -define png:big-depth=16 -define png:color-type=6 -sample 32x32 "${ICONSET}/icon_16x16@2x.png" convert "${SOURCE}" -define png:big-depth=16 -define png:color-type=6 -sample 32x32 "${ICONSET}/icon_16x16@2x.png"
@ -90,3 +99,4 @@ iconutil -c icns "${ICONSET}" -o ${DEST}
# Clean up the iconset # Clean up the iconset
rm -rf "${ICONSET}" rm -rf "${ICONSET}"

View File

@ -42,23 +42,19 @@ function iconBuild(options, callback) {
return; return;
} }
if (iconIsPng(options.icon)) { if (!isOSX()) {
console.warn('Conversion of `.png` to `.icns` for OSX app is only supported on OSX');
if (!isOSX()) { returnCallback();
console.warn('Conversion of `.png` to `.icns` for OSX app is only supported on OSX'); return;
returnCallback();
return;
}
pngToIcns(options.icon, (error, icnsPath) => {
options.icon = icnsPath;
if (error) {
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
}
returnCallback();
return;
});
} }
pngToIcns(options.icon, (error, icnsPath) => {
options.icon = icnsPath;
if (error) {
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
}
returnCallback();
});
} }
function iconIsPng(iconPath) { function iconIsPng(iconPath) {