osx-fileicon

Get the Finder icon for a file path

Usage no npm install needed!

<script type="module">
  import osxFileicon from 'https://cdn.skypack.dev/osx-fileicon';
</script>

README

macIconForFile npm version

Get the native macOS icon for a specific file extension as a PNG image buffer.

Inspired and based on:

Retrieves icon, exactly the same way as Finder does it, including QuickLook preview generation in case if it's possible. This is a ultra-stripped re-implementation of the above repo replacing deprecated code

Installation

npm install mac-file-icon

Usage

var getIconForFile = require("osx-fileicon");
getIconForFile("/Users/", function (buffer) {
  console.info(buffer);
});

You can always convert Buffer into its base64 representation:

var getIconForFile = require("mac-file-icon");
getIconForFile("/Users/", function (buffer) {
  console.info(buffer.toString("base64"));
});

By default, icon size is set to 500x500 for previewing.