Skip to content

Commit

Permalink
Pass on encoding:auto to WPC for api=2. Closes #168
Browse files Browse the repository at this point in the history
  • Loading branch information
rosell-dk committed Jun 15, 2019
1 parent 8298cf1 commit 50f59ca
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 33 deletions.
29 changes: 18 additions & 11 deletions src-build/webp-convert.inc
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,11 @@ abstract class AbstractConverter
$this->logLn('Trace:');
foreach ($e->getTrace() as $trace) {
//$this->logLn(print_r($trace, true));
$this->logLn(
$trace['file'] . ':' . $trace['line']
);
if (isset($trace['file']) && isset($trace['line'])) {
$this->logLn(
$trace['file'] . ':' . $trace['line']
);
}
}
throw $e;
} /*catch (\Error $e) {
Expand Down Expand Up @@ -4832,6 +4834,18 @@ class Wpc extends AbstractConverter
return [];
}

public function supportsLossless()
{
return ($this->options['api-version'] >= 2);
}

public function passOnEncodingAuto()
{
// We could make this configurable. But I guess passing it on is always to be preferred
// for api >= 2.
return ($this->options['api-version'] >= 2);
}

protected function createOptions()
{
parent::createOptions();
Expand All @@ -4841,18 +4855,11 @@ class Wpc extends AbstractConverter
new SensitiveStringOption('secret', ''), /* for communicating with wpc api v.0 */
new SensitiveStringOption('api-url', ''),
new SensitiveStringOption('url', ''), /* DO NOT USE. Only here to keep the protection */
new IntegerOption('api-version', 1, 0, 2),
new IntegerOption('api-version', 2, 0, 2),
new BooleanOption('crypt-api-key-in-transfer', false) /* new in api v.1 */
);
}

public function passOnEncodingAuto()
{
// We could make this configurable. But I guess passing it on is always to be preferred (except for
// api = 1, but people ought to update their wpc anyway)
return true;
}

private static function createRandomSaltForBlowfish()
{
$salt = '';
Expand Down
29 changes: 18 additions & 11 deletions src-build/webp-on-demand-2.inc
Original file line number Diff line number Diff line change
Expand Up @@ -458,9 +458,11 @@ abstract class AbstractConverter
$this->logLn('Trace:');
foreach ($e->getTrace() as $trace) {
//$this->logLn(print_r($trace, true));
$this->logLn(
$trace['file'] . ':' . $trace['line']
);
if (isset($trace['file']) && isset($trace['line'])) {
$this->logLn(
$trace['file'] . ':' . $trace['line']
);
}
}
throw $e;
} /*catch (\Error $e) {
Expand Down Expand Up @@ -4754,6 +4756,18 @@ class Wpc extends AbstractConverter
return [];
}

public function supportsLossless()
{
return ($this->options['api-version'] >= 2);
}

public function passOnEncodingAuto()
{
// We could make this configurable. But I guess passing it on is always to be preferred
// for api >= 2.
return ($this->options['api-version'] >= 2);
}

protected function createOptions()
{
parent::createOptions();
Expand All @@ -4763,18 +4777,11 @@ class Wpc extends AbstractConverter
new SensitiveStringOption('secret', ''), /* for communicating with wpc api v.0 */
new SensitiveStringOption('api-url', ''),
new SensitiveStringOption('url', ''), /* DO NOT USE. Only here to keep the protection */
new IntegerOption('api-version', 1, 0, 2),
new IntegerOption('api-version', 2, 0, 2),
new BooleanOption('crypt-api-key-in-transfer', false) /* new in api v.1 */
);
}

public function passOnEncodingAuto()
{
// We could make this configurable. But I guess passing it on is always to be preferred (except for
// api = 1, but people ought to update their wpc anyway)
return true;
}

private static function createRandomSaltForBlowfish()
{
$salt = '';
Expand Down
8 changes: 5 additions & 3 deletions src/Convert/Converters/AbstractConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,11 @@ public function doConvert()
$this->logLn('Trace:');
foreach ($e->getTrace() as $trace) {
//$this->logLn(print_r($trace, true));
$this->logLn(
$trace['file'] . ':' . $trace['line']
);
if (isset($trace['file']) && isset($trace['line'])) {
$this->logLn(
$trace['file'] . ':' . $trace['line']
);
}
}
throw $e;
} /*catch (\Error $e) {
Expand Down
21 changes: 13 additions & 8 deletions src/Convert/Converters/Wpc.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ protected function getUnsupportedDefaultOptions()
return [];
}

public function supportsLossless()
{
return ($this->options['api-version'] >= 2);
}

public function passOnEncodingAuto()
{
// We could make this configurable. But I guess passing it on is always to be preferred
// for api >= 2.
return ($this->options['api-version'] >= 2);
}

protected function createOptions()
{
parent::createOptions();
Expand All @@ -41,18 +53,11 @@ protected function createOptions()
new SensitiveStringOption('secret', ''), /* for communicating with wpc api v.0 */
new SensitiveStringOption('api-url', ''),
new SensitiveStringOption('url', ''), /* DO NOT USE. Only here to keep the protection */
new IntegerOption('api-version', 1, 0, 2),
new IntegerOption('api-version', 2, 0, 2),
new BooleanOption('crypt-api-key-in-transfer', false) /* new in api v.1 */
);
}

public function passOnEncodingAuto()
{
// We could make this configurable. But I guess passing it on is always to be preferred (except for
// api = 1, but people ought to update their wpc anyway)
return true;
}

private static function createRandomSaltForBlowfish()
{
$salt = '';
Expand Down

0 comments on commit 50f59ca

Please sign in to comment.