mirror of
https://github.com/Llewellynvdm/nativefier.git
synced 2025-01-03 14:17:29 +00:00
Implement conversion to ico for windows target
This commit is contained in:
parent
1862d7cafe
commit
54b251ee1c
45
bin/convertToIco
Executable file
45
bin/convertToIco
Executable file
@ -0,0 +1,45 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# USAGE
|
||||||
|
|
||||||
|
# ./convertToIco <input png or ico> <outfilename>.ico
|
||||||
|
# Example
|
||||||
|
# ./convertToPng ~/sample.png ~/converted.ico
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
IMAGEMAGICK_CONVERT=$(which convert)
|
||||||
|
IMAGEMAGICK_IDENTIFY=$(which identify)
|
||||||
|
|
||||||
|
if [ ! -x "${IMAGEMAGICK_CONVERT}" ]; then
|
||||||
|
echo "Cannot find required ImageMagick Convert executable" >&2
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
if [ ! -x "${IMAGEMAGICK_IDENTIFY}" ]; then
|
||||||
|
echo "Cannot find required ImageMagick Identify executable" >&2
|
||||||
|
exit 1;
|
||||||
|
fi
|
||||||
|
|
||||||
|
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##*.}"
|
||||||
|
BASE="${NAME%.*}"
|
||||||
|
|
||||||
|
if [ "${EXT}" == "ico" ]; then
|
||||||
|
cp "${SOURCE}" "${DEST}"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
convert "${SOURCE}" "${DEST}"
|
@ -3,7 +3,7 @@ import helpers from './../helpers/helpers';
|
|||||||
import iconShellHelpers from './../helpers/iconShellHelpers';
|
import iconShellHelpers from './../helpers/iconShellHelpers';
|
||||||
|
|
||||||
const {isOSX} = helpers;
|
const {isOSX} = helpers;
|
||||||
const {convertToPng, convertToIcns} = iconShellHelpers;
|
const {convertToPng, convertToIco, convertToIcns} = iconShellHelpers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @callback augmentIconsCallback
|
* @callback augmentIconsCallback
|
||||||
@ -30,11 +30,20 @@ function iconBuild(options, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (options.platform === 'win32') {
|
if (options.platform === 'win32') {
|
||||||
if (!iconIsIco(options.icon)) {
|
if (iconIsIco(options.icon)) {
|
||||||
console.warn('Icon should be an .ico to package for Windows');
|
returnCallback();
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
returnCallback();
|
convertToIco(options.icon)
|
||||||
|
.then(outPath => {
|
||||||
|
options.icon = outPath;
|
||||||
|
returnCallback();
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.warn('Skipping icon conversion to .ico', error);
|
||||||
|
returnCallback();
|
||||||
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ tmp.setGracefulCleanup();
|
|||||||
const SCRIPT_PATHS = {
|
const SCRIPT_PATHS = {
|
||||||
singleIco: path.join(__dirname, '../..', 'bin/singleIco'),
|
singleIco: path.join(__dirname, '../..', 'bin/singleIco'),
|
||||||
convertToPng: path.join(__dirname, '../..', 'bin/convertToPng'),
|
convertToPng: path.join(__dirname, '../..', 'bin/convertToPng'),
|
||||||
|
convertToIco: path.join(__dirname, '../..', 'bin/convertToIco'),
|
||||||
convertToIcns: path.join(__dirname, '../..', 'bin/convertToIcns')
|
convertToIcns: path.join(__dirname, '../..', 'bin/convertToIcns')
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -58,6 +59,10 @@ function convertToPng(icoSrc) {
|
|||||||
return iconShellHelper(SCRIPT_PATHS.convertToPng, icoSrc, `${getTmpDirPath()}/icon.png`);
|
return iconShellHelper(SCRIPT_PATHS.convertToPng, icoSrc, `${getTmpDirPath()}/icon.png`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function convertToIco(icoSrc) {
|
||||||
|
return iconShellHelper(SCRIPT_PATHS.convertToIco, icoSrc, `${getTmpDirPath()}/icon.ico`);
|
||||||
|
}
|
||||||
|
|
||||||
function convertToIcns(icoSrc) {
|
function convertToIcns(icoSrc) {
|
||||||
if (!isOSX()) {
|
if (!isOSX()) {
|
||||||
return new Promise((resolve, reject) => reject('OSX is required to convert to a .icns icon'));
|
return new Promise((resolve, reject) => reject('OSX is required to convert to a .icns icon'));
|
||||||
@ -68,5 +73,6 @@ function convertToIcns(icoSrc) {
|
|||||||
export default {
|
export default {
|
||||||
singleIco,
|
singleIco,
|
||||||
convertToPng,
|
convertToPng,
|
||||||
|
convertToIco,
|
||||||
convertToIcns
|
convertToIcns
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user