Skip to content
rejettoPublic

About

HFS plugin offering Sharp and Level-db libraries to other plugins

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Repository files navigation

Sharp

HFS plugin offering sharp and level-db libraries to other plugins.

Use sharp by calling api.customApiCall('sharp', buffer).find(Boolean).

Since version 1.4, a native-library load failure is logged without stopping the plugin, so dependent plugins can still start and use their own fallback. In that case the sharp API is unavailable; callers must check for a result before using it.

Access level by calling api.customApiCall('level')[0]

Eseguire comandi Sharp in un processo separato

Per delegare una pipeline Sharp ad un processo figlio ed ottenere il risultato come Buffer, usa la funzione runSharpCommands:

const [runSharpCommands] = await api.customApiCall('runSharpCommands')

const buffer = await runSharpCommands(imageBuffer, [
    ['resize', width, height, { fit: 'inside' }],
    ['rotate'],
    ['jpeg', { quality: 80 }],
])

Ogni operazione è un array composto dal nome del metodo Sharp seguito dagli argomenti da passare. Il worker esegue sempre toBuffer() al termine e restituisce il risultato nella promise.

Per liberare il processo dedicato (ad esempio in fase di shutdown) puoi invocare:

const [disposeSharpWorker] = await api.customApiCall('disposeSharpWorker')
disposeSharpWorker()

About

HFS plugin offering Sharp and Level-db libraries to other plugins

Topics

Resources

Stars

5 stars

Watchers

1 watching

Forks

Contributors

Languages