bb-fat / electron-icns-ex Goto Github PK
View Code? Open in Web Editor NEWA native module to parse icns file for electron.
A native module to parse icns file for electron.
Hi, I'm trying to create a node util to find some apps by name, and get an object with name,path,icon
I already got the part to get the apps, and now I want to convert the icns to base64 but string is always empty and no error..
this is what I have on a simple test.js
const { parseIcnsToBase64, parseIcnsToBase64Sync } = require('electron-icns-ex');
const getAppInfo = (path) => {
const name = path.match(/([\w\d\s_-]*)\.?[^\\\/]*$/)[1];
const icnsFile = getCFBundleIconFileSync(path);
const icnsPath = `${path.replaceAll(' ', '\\ ')}/Contents/Resources/${icnsFile}`;
const icon = parseIcnsToBase64Sync(icnsPath);
return {
name,
path,
icon
}
}
const getCFBundleIconFileSync = (appPath) => {
const plistPath = `${appPath.replaceAll(' ', '\\ ')}/Contents/Info.plist`;
const getIconFilenameCmd = `plutil -convert xml1 -o - ${plistPath} | sed -n '/CFBundleIconFile/,/\\//p' | sed -n '/<string>/,/<\\/string>/p' | sed 's/string>/\/g' | sed 's/<//g' | sed 's/\\///g' | awk '{$1=$1};1'`;
return execSync(getIconFilenameCmd).toString();
}
Do I have to do anything else besides install the package with npm?
Could you help me to figure out what am I missing?
const icns = require('electron-icns-ex');
parseIcnsToPNG(localIconPath, pngPath); // localIconPath defined erlier in the code
const img = document.querySelector("#localIcon");
img.src = pngPath;
error:
pngPath is not defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.