ScienceVikings/IconExtractor

语言: C#

git: https://github.com/ScienceVikings/IconExtractor

nodejs包,返回路径图标的base64图像数据。
A nodejs package that returns base64 image data for a path's icon.
README.md (中文)

IconExtractor

nodejs包,返回路径图标的base64图像数据。

这是一个.net可执行文件的简单nodejs包装器,它将从给定路径中提取图标图像数据并将其返回。

获取图标提取器的实例

var iconExtractor = require('icon-extractor');

此对象包含具有两个事件(图标和错误)的事件发射器

要获取图标的数据,您需要调用getIcon函数,该函数需要两个参数。 第一个是上下文参数。这将返回图标数据,以便您可以获得有关返回的信息 数据是为了。第二个参数是您想要图标的文件的路径。

然后,你需要在发射器上听取像这样的图标数据

iconExtractor.emitter.on('icon',function(iconData){/ *在这里做东西* /});

此数据作为json对象返回,包含三个字段:Context,Path和Base64ImageData

这是一个放在一起的例子

var iconExtractor = require('icon-extractor');

iconExtractor.emitter.on('icon', function(data){
  console.log('Here is my context: ' + data.Context);
  console.log('Here is the path it was for: ' + data.Path);
  console.log('Here is the base64 image: ' + data.Base64ImageData);
});

iconExtractor.getIcon('SomeContextLikeAName','c:\myexecutable.exe');

本文使用googletrans自动翻译,仅供参考, 原文来自github.com

en_README.md

IconExtractor

A nodejs package that returns base64 image data for a path's icon.

This is a simple nodejs wrapper around a .net executable that will extract icon image data from a given path and return it.

Get an instance of the icon extractor with

var iconExtractor = require('icon-extractor');

This object contains an event emitter with two events, icon and error

To get an icon's data you need to call the getIcon function which takes two parameters.
The first is a context parameter. This will return with the icon data so you can have some information about what the return
data is for. The second parameter is the path of the file you want the icon for.

Then, you need to listen on the emitter for the icon data like this

iconExtractor.emitter.on('icon', function(iconData){ /*do stuff here*/ });

This data comes back as a json object containing three fields, Context, Path and Base64ImageData

Here is an example of it all put together

var iconExtractor = require('icon-extractor');

iconExtractor.emitter.on('icon', function(data){
  console.log('Here is my context: ' + data.Context);
  console.log('Here is the path it was for: ' + data.Path);
  console.log('Here is the base64 image: ' + data.Base64ImageData);
});

iconExtractor.getIcon('SomeContextLikeAName','c:\myexecutable.exe');