Skip to content

Commit a2303bf

Browse files
committed
Add options for 'nclx' & 'rate'
1 parent 6d52f9f commit a2303bf

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ You may also change certain options from your `config.php` globally, like this:
8585
| `'deflum'` | integer | `80` | default/fallback luminance value in nits |
8686
| `'hlglum'` | integer | `null` | Like `'deflum'`, but uses an appropriate diffuse white based on peak HLG |
8787
| `'jobs'` | integer | `0` | Number of jobs to use when working (`0` = unlimited) |
88+
| `'nclx'` | string | `null` | Force the output NCLX color profile to specific values: PRI,TF,MTX (AVIF only) |
89+
| `'rate'` | integer | `0` | Output rate for for supported output formats. If `0`, codec uses quality value |
8890
| `'speed'` | integer | `'auto'` | Quality/speed tradeoff when encoding (AVIF only); `0` = best quality, `10` = fastest |
8991
| `'template'` | string | `null` | Set file blueprint for images generated with `toFormat()` |
9092
| `'tonemap'` | string|bool | `'auto'` | Set tonemapping (`'on'` or `'off'`, but `true` & `false` are possible, too) |

src/Colorist.php

+27-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ protected function defaults(): array
2929
'format' => null,
3030
'hlglum' => option('fundevogel.colorist.hlglum', null),
3131
'jobs' => option('fundevogel.colorist.jobs', 0),
32+
'nclx' => option('fundevogel.colorist.nclx', null),
33+
'rate' => option('fundevogel.colorist.rate', 0),
3234
'speed' => option('fundevogel.colorist.speed', null),
3335
'tonemap' => option('fundevogel.colorist.tonemap', null),
3436
'yuv' => option('fundevogel.colorist.yuv', null),
@@ -307,7 +309,11 @@ protected function hlglum(array $options): string
307309
# See https://github.com/joedrago/colorist/blob/master/docs/Usage.md#-j---jobs
308310
protected function jobs(array $options): string
309311
{
310-
return '--jobs ' . $options['jobs'];
312+
if ($options['jobs'] > 0) {
313+
return '--jobs ' . $options['jobs'];
314+
}
315+
316+
return '';
311317
}
312318

313319
# (2) Output format options
@@ -350,6 +356,24 @@ protected function format(array $options): string
350356
return '';
351357
}
352358

359+
protected function nclx(array $options): string
360+
{
361+
if ($options['nclx'] !== null) {
362+
return '--nclx ' . $options['nclx'];
363+
}
364+
365+
return '';
366+
}
367+
368+
protected function rate(array $options): string
369+
{
370+
if ($options['rate'] > 0) {
371+
return '--rate ' . $options['rate'];
372+
}
373+
374+
return '';
375+
}
376+
353377
protected function speed(array $options): string
354378
{
355379
if ($options['speed'] === null) {
@@ -478,6 +502,8 @@ public function process(string $file, array $options = []): array
478502
# (3) Output format options
479503
$command[] = $this->bpc($options);
480504
$command[] = $this->format($options);
505+
$command[] = $this->nclx($options);
506+
$command[] = $this->rate($options);
481507
$command[] = $this->speed($options);
482508
$command[] = $this->tonemap($options);
483509
$command[] = $this->yuv($options);

0 commit comments

Comments
 (0)