Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/insanity54/node-gimp
Communicate with GIMP's Script-Fu server via node.js
https://github.com/insanity54/node-gimp
Last synced: 8 days ago
JSON representation
Communicate with GIMP's Script-Fu server via node.js
- Host: GitHub
- URL: https://github.com/insanity54/node-gimp
- Owner: insanity54
- License: unlicense
- Created: 2022-09-02T05:44:12.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-09-18T02:00:47.000Z (over 2 years ago)
- Last Synced: 2024-12-20T21:58:29.287Z (17 days ago)
- Language: JavaScript
- Size: 53.7 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# node-gimp
Send Script-Fu commands from Node.js to GIMP. Can be used to set colors, create text or layers, run filters, you name it.
@todo insert cool video
## Usage
Here's an example using promises.
```js
// my-cool-program.jsimport Gimp from 'node-gimp';
(async function main() {
const gimp = new Gimp();
const res = await gimp.sendCommand('(gimp-image-list)');
console.log(res); // => { raw: '(1 #(1))', jse: [ 1, '#', [ 1 ] ] }
})();```
The Gimp() constructor can be passed options.
```js
const options = {
port: 38483, // defaults to 10008
responseTimeout: 100 // defaults to 1000
};
const gimp = new Gimp(options);
```### Events
A node-gimp class instance emits the following events
* connect
* data
* errorThese can be listened to by your code.
#### Events Example
```js
const gimp = new Gimp();gimp.on('connect', () => {
console.log('GIMP connection established!');
})/**
* data event payload includes responses
* to the commands that we send to Gimp.
*/
gimp.on('data', (data) => {
console.log('GIMP sent us some data!')// data variable will contain an object with the {String} response from Script-Fu server,
// as well as a javascript expression (jse) of that response.
// example: { raw: '#t', jse: [true] }
console.log(data);
})gimp.on('error', (e) => {
console.error('GIMP emitted an error!')
console.error(e)
})const exampleCommand = `(gimp-context-set-foreground '(255 0 255))`;
gimp.sendCommand(exampleCommand);
```