Skip to content

Commit

Permalink
Merge 64d90d4 into 28a9248
Browse files Browse the repository at this point in the history
  • Loading branch information
psytraxx committed Jan 1, 2018
2 parents 28a9248 + 64d90d4 commit ad098d2
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions Imagine/Filter/PostProcessor/JpegOptimPostProcessor.php
Expand Up @@ -15,7 +15,7 @@
use Liip\ImagineBundle\Binary\FileBinaryInterface;
use Liip\ImagineBundle\Model\Binary;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\ProcessBuilder;
use Symfony\Component\Process\Process;

class JpegOptimPostProcessor implements PostProcessorInterface, ConfigurablePostProcessorInterface
{
Expand Down Expand Up @@ -141,33 +141,32 @@ public function processWithConfiguration(BinaryInterface $binary, array $options
throw new \RuntimeException(sprintf('Temp file can not be created in "%s".', $tempDir));
}

$pb = new ProcessBuilder([$this->jpegoptimBin]);

$commandline = $this->jpegoptimBin;
$stripAll = array_key_exists('strip_all', $options) ? $options['strip_all'] : $this->stripAll;
if ($stripAll) {
$pb->add('--strip-all');
$commandline .= ' --strip-all';
}

$max = array_key_exists('max', $options) ? $options['max'] : $this->max;
if ($max) {
$pb->add('--max='.$max);
$commandline .= ' --max='.$max;
}

$progressive = array_key_exists('progressive', $options) ? $options['progressive'] : $this->progressive;
if ($progressive) {
$pb->add('--all-progressive');
$commandline .= ' --all-progressive';
} else {
$pb->add('--all-normal');
$commandline .= ' --all-normal';
}

$pb->add($input);
$commandline .= ' '.$input;
if ($binary instanceof FileBinaryInterface) {
copy($binary->getPath(), $input);
} else {
file_put_contents($input, $binary->getContent());
}

$proc = $pb->getProcess();
$proc = new Process($commandline);
$proc->run();

if (false !== strpos($proc->getOutput(), 'ERROR') || 0 !== $proc->getExitCode()) {
Expand Down

3 comments on commit ad098d2

@sebastianblum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you see #1025 ?

@psytraxx
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hi - yes i did - and as a result i deleted my PR and my code - its much better better what i did and now i hope it will be merged soon because i need this code :)

@sebastianblum
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@psytraxx I have the same issue. I created the pull request #1029 today that the Tests are executed again and hopefully now pull requests can be merged into the 2.0 branch

Please sign in to comment.