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
|
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}"
|
||||||
|
|
||||||
|
@ -42,8 +42,6 @@ function iconBuild(options, callback) {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (iconIsPng(options.icon)) {
|
|
||||||
|
|
||||||
if (!isOSX()) {
|
if (!isOSX()) {
|
||||||
console.warn('Conversion of `.png` to `.icns` for OSX app is only supported on OSX');
|
console.warn('Conversion of `.png` to `.icns` for OSX app is only supported on OSX');
|
||||||
returnCallback();
|
returnCallback();
|
||||||
@ -56,10 +54,8 @@ function iconBuild(options, callback) {
|
|||||||
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
|
console.warn('Skipping icon conversion from `.png` to `.icns`: ', error);
|
||||||
}
|
}
|
||||||
returnCallback();
|
returnCallback();
|
||||||
return;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function iconIsPng(iconPath) {
|
function iconIsPng(iconPath) {
|
||||||
return path.extname(iconPath) === '.png';
|
return path.extname(iconPath) === '.png';
|
||||||
|
Loading…
Reference in New Issue
Block a user