release/1.0
Clovis Gauzy 2020-11-26 17:58:42 +01:00
parent e1e0a8a5d4
commit 8e92c0c14e
3 changed files with 109 additions and 23 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/node_modules
*.lock
*.md.backup

113
README.md
View File

@ -22,24 +22,15 @@ npm i --save rawtherapee
yarn add rawtherapee
```
## Simple Usage
## Usage
```js
const rawtherapee = require("rawtherapee");
_Promise_ = rawtherapee(_url_ | _array_ `targets` [, _object_ `options`])
rawtherapee("/somewhere/something.NEF").then((files) => {
// `files` is an array containing all processed file paths.
console.log(files.length, "files processed.");
});
```
* `targets`: files or directories
* `options`: simple options _Object_
### Options
| option | format | values | default |
|!===|===|===|===|
| replace | _boolean_ | | |
#### `replace`
*default: `false`*
@ -51,12 +42,23 @@ Replace the existing output file.
*default: `false`*
Process all raw and non raw formats, igroring GUI parameters.
#### `presets`
*default: `['default']`*
'sidecar', 'sidecar-strict', '<uri>'
An array of pp3 presets files.
Possible opions:
* `'default'`: use the default preset selected in GUI.
* `'sidecar'`: use the sidecar file of each image if available
* `'sidecar-strict'`: like `'sidecar`, but return an error if there is no sidecar.
* `<uri>`: any pp3 file in your system
`rawtherapee-cli` always use the neutral presets as base, then apply presets in the order you passed it.
#### `ignoreBadPreset`
@ -66,16 +68,20 @@ Replace the existing output file.
If set to `false`, any non-existing preset file passed to the `presets` parameter will throw an error.
If set to `true`, those files will be ignored (not passed to `rawtherapi-cli`) and print message in `sterr` if the `DEBUG` environment variable is set to any value.
#### `output`
*default: `'/tmp/img'`*
*default: `'.'`*
File or directory where the processed files will be stored (directory must exists).
#### `format`
*default: `'jpg'`*
Possibles options:
`'jpg'`, `'png'` or `'tiff'`
@ -83,13 +89,16 @@ If set to `true`, those files will be ignored (not passed to `rawtherapi-cli`) a
*default: `8`*
`16`, `16f` or `32`
Only for TIFF and PNG output formats.
Color depth of the output file. Only for TIFF and PNG formats.
Possibles options:
`8` or `16`
#### `compression`
*default: `92`*
*default: `90`*
Only for JPG output formats (PNG compression is hardcoded at 6 in `rawtherapi-cli`)
@ -98,9 +107,13 @@ Only for JPG output formats (PNG compression is hardcoded at 6 in `rawtherapi-cl
_string_ or _int_
*default:`'4:2:2'`*
*default:`2`*
`1`, `'4:2:0'`, `2`, `'4:4:4'`, `3`
Possibles options:
* `'4:2:2'` or `1`
* `'4:2:0'` or `2`
* `'4:4:4'` or `3`
#### `zip`
@ -109,7 +122,7 @@ _boolean_
*default: `false`*
Only for TIFF output format.
Use TIFF zip compression.
#### `onChange`
@ -117,8 +130,62 @@ Only for TIFF output format.
_function_
*default: `() => {}`*
Callback _function_ fired every time the status is updated (not based on `EventListener`) :
Callback _function_ fired every time the status is updated (not using `EventListeners`) :
Return a simple object who always contains `status` entry, and maybe `file` or `code`.
Return a simple object who always contains `status`, and maybe `file` or `code`.
Status can be :
* `start`: start running `rawtherapee-cli`.
* `skipped`: skip ignored `file` in a full directory process.
* `processing`: start processing `file`.
* `complete`: processing `file` completed.
* `idle`: `rawtherapee-cli` stop with `code` code.
### Examples
```js
const rawtherapee = require('rawtherapee')
rawtherapee('/somewhere/something.NEF')
.then((files) => {
console.log(files.length, 'files processed.')
})
```
```js
const fs = require('fs')
const rawtherapee = require('rawtherapee')
const output = '/tmp/img'
if (!fs.existsSync(output)) fs.mkdirSync(output)
const onChange = (state) => {
switch (state.status) {
case 'complete':
console.log(state.file, 'process done.')
break
case 'skipped':
console.log(state.file, 'have been ignored.')
break
default:
console.log('Event', state.status, 'fired.', state)
}
}
rawtherapee([
'/somewhere/something.NEF',
'/somewhereelse/somethingelse.NEF'
], {
onChange,
output,
format: 'tiff',
depth: 16,
zip: true,
preset: ['sidecar']
})
.then((files) => console.log(files.length, 'files processed.'))
```

16
package.json Normal file
View File

@ -0,0 +1,16 @@
{
"name": "rawtherapee",
"version": "0.1.0",
"description": "rawtherapee-cli wrapper to process RAW images in NodeJs",
"repository": "https://github.com/clovfr/node-rawtherapee",
"author": "Clovis Gauzy",
"license": "BSD-3",
"private": true,
"main": "rawtherapee.js",
"scripts": {
"test": "standard"
},
"devDependencies": {
"standard": "*"
}
}