Skip to content

Commit

Permalink
Reorder parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
S1SYPHOS committed Nov 5, 2020
1 parent ed103b2 commit 4832030
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 38 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "Kirby v3 wrapper for colorist",
"type": "kirby-plugin",
"license": "MIT",
"version": "1.7.0",
"version": "1.8.0",
"keywords": ["kirby3", "image", "graphics"],
"homepage": "https://github.com/Fundevogel/kirby3-colorist#readme",
"authors": [
Expand Down
75 changes: 38 additions & 37 deletions src/Colorist.php
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,16 @@ protected function resize(string $file, array $options): string

# (1) Basic options

# See https://github.com/joedrago/colorist/blob/master/docs/Usage.md#-j---jobs
protected function jobs(array $options): string
{
if ($options['jobs'] > 0) {
return '--jobs ' . $options['jobs'];
}

return '';
}

# See https://github.com/joedrago/colorist/blob/master/docs/Usage.md#--cmm---cms
protected function cmm(array $options): string
{
Expand Down Expand Up @@ -325,16 +335,6 @@ protected function hlglum(array $options): string
return '';
}

# See https://github.com/joedrago/colorist/blob/master/docs/Usage.md#-j---jobs
protected function jobs(array $options): string
{
if ($options['jobs'] > 0) {
return '--jobs ' . $options['jobs'];
}

return '';
}

# (2) Input profile options
protected function iccin(array $options): string
{
Expand Down Expand Up @@ -487,15 +487,7 @@ protected function format(array $options): string
return '';
}

protected function nclx(array $options): string
{
if ($options['nclx'] !== null) {
return '--nclx ' . $options['nclx'];
}

return '';
}

# See https://github.com/joedrago/colorist/blob/master/docs/Usage.md#-r---rate
protected function rate(array $options): string
{
if ($options['rate'] > 0) {
Expand All @@ -505,22 +497,6 @@ protected function rate(array $options): string
return '';
}

protected function speed(array $options): string
{
if ($options['speed'] === null) {
return '';
}

$min = 0;
$max = 10;

if (($min <= (int) $options['speed']) && ((int) $options['speed'] <= $max)) {
return '--speed ' . $options['speed'];
}

return '';
}

# See https://github.com/joedrago/colorist/blob/master/docs/Usage.md#-t---tonemap
protected function tonemap(array $options): string
{
Expand Down Expand Up @@ -562,6 +538,31 @@ protected function yuv(array $options): string
return '';
}

protected function speed(array $options): string
{
if ($options['speed'] === null) {
return '';
}

$min = 0;
$max = 10;

if (($min <= (int) $options['speed']) && ((int) $options['speed'] <= $max)) {
return '--speed ' . $options['speed'];
}

return '';
}

protected function nclx(array $options): string
{
if ($options['nclx'] !== null) {
return '--nclx ' . $options['nclx'];
}

return '';
}


/**
* Core
Expand Down Expand Up @@ -645,11 +646,11 @@ public function process(string $file, array $options = []): array
# (5) Output format options
$command[] = $this->bpc($options);
$command[] = $this->format($options);
$command[] = $this->nclx($options);
$command[] = $this->rate($options);
$command[] = $this->speed($options);
$command[] = $this->tonemap($options);
$command[] = $this->yuv($options);
$command[] = $this->speed($options);
$command[] = $this->nclx($options);
# (6) Save image
$command[] = $this->save($file);

Expand Down

0 comments on commit 4832030

Please sign in to comment.