3.1.0 • Published 2 years ago

@todesktop/file-icon-prebuild v3.1.0

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years ago

file-icon Build Status

Get the icon of a file or app as a PNG image (macOS)

Install

$ npm install file-icon

Usage

const fs = require('fs');
const fileIcon = require('file-icon');

(async () => {
	const buffer = await fileIcon.buffer('Safari')
	fs.writeFileSync('safari-icon.png', buffer);

	// Or by bundle ID
	const buffer2 = await fileIcon.buffer('com.apple.Safari', {size: 64});
	fs.writeFileSync('safari-icon.png', buffer2);

	// Or by filename
	const buffer3 = await fileIcon.buffer('unicorn.jpg');
	fs.writeFileSync('jpeg-file-type-icon.png', buffer3);

	await fileIcon.file('Safari', {destination: 'safari-icon.png'});
	console.log('Done');
})();

API

fileIcon.buffer(input, options)

Returns a Promise<Buffer> for a PNG image.

input

Type: string number

Either:

  • App name (string)
  • App bundle identifier (string)
  • App process ID (number)
  • Path to an app (string)
  • Path to a file (string)

options

Type: Object

size

Type: number Default: 1024 Maximum: 1024

Size of the returned icon.

fileIcon.file(input, options)

Returns a Promise for when the file is written to destination.

options

Type: Object

size

Type: number Default: 1024 Maximum: 1024

Size of the returned icon.

destination

Required Type: string

Output file for the icon.

Related

License

MIT © Sindre Sorhus