mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2024-11-11 07:41:04 +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:
parent
3f6f632d51
commit
f48ad3790b
@ -29,7 +29,7 @@ fi
|
||||
SOURCE=$1
|
||||
DEST=$2
|
||||
|
||||
# Get source image
|
||||
# Check source and destination arguments
|
||||
if [ -z "${SOURCE}" ]; then
|
||||
echo "No source image specified"
|
||||
exit 1
|
||||
@ -41,13 +41,23 @@ if [ -z "${DEST}" ]; then
|
||||
fi
|
||||
|
||||
|
||||
|
||||
# File Infrastructure
|
||||
NAME=$(basename "${SOURCE}")
|
||||
EXT="${NAME##*.}"
|
||||
BASE="${NAME%.*}"
|
||||
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
|
||||
# echo "SOURCE: ${SOURCE}"
|
||||
# echo "NAME: $NAME"
|
||||
@ -71,7 +81,6 @@ ICONSET="${BASE}.iconset"
|
||||
#fi
|
||||
|
||||
# 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 32x32 "${ICONSET}/icon_16x16@2x.png"
|
||||
@ -90,3 +99,4 @@ iconutil -c icns "${ICONSET}" -o ${DEST}
|
||||
|
||||
# Clean up the iconset
|
||||
rm -rf "${ICONSET}"
|
||||
|
||||
|
@ -42,8 +42,6 @@ function iconBuild(options, callback) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (iconIsPng(options.icon)) {
|
||||
|
||||
if (!isOSX()) {
|
||||
console.warn('Conversion of `.png` to `.icns` for OSX app is only supported on OSX');
|
||||
returnCallback();
|
||||
@ -56,9 +54,7 @@ function iconBuild(options, callback) {
|
||||
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
|
||||
}
|
||||
returnCallback();
|
||||
return;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function iconIsPng(iconPath) {
|
||||
|
Loading…
Reference in New Issue
Block a user