X-Git-Url: https://git.cweiske.de/phancap.git/blobdiff_plain/62875bdbecc633496c712bc2fc5e0ef8f54733e3..9a568c09ae8cef2f0222e82dc93ed122615c2590:/src/phancap/Adapter/Cutycapt.php diff --git a/src/phancap/Adapter/Cutycapt.php b/src/phancap/Adapter/Cutycapt.php new file mode 100644 index 0000000..173a86c --- /dev/null +++ b/src/phancap/Adapter/Cutycapt.php @@ -0,0 +1,57 @@ +getPath() . '-tmp'; + $cmd = 'cutycapt' + . ' --url=' . escapeshellarg($options->values['url']) + . ' --out-format=' . escapeshellarg($options->values['sformat']) + . ' --out=' . escapeshellarg($tmpPath) + . ' --max-wait=10000' + . ' --min-width=' . $options->values['bwidth']; + if ($options->values['bheight'] !== null) { + $cmd .= ' --min-height=' . $options->values['bheight']; + } + + $xvfbcmd = 'xvfb-run' + . ' -e /dev/stdout' + . ' --server-args="-screen 0, 1024x768x24"'; + Executor::run($xvfbcmd . ' ' . $cmd); + + $this->resize($tmpPath, $img, $options); + } + + protected function resize($tmpPath, $img, $options) + { + if ($options->values['sformat'] == 'pdf') { + //nothing to resize. + rename($tmpPath, $img->getPath()); + return; + } + + $crop = ''; + if ($options->values['smode'] == 'screen') { + $crop = ' -crop ' . $options->values['swidth'] + . 'x' . $options->values['sheight'] + . '+0x0'; + } + + $convertcmd = 'convert' + . ' ' . escapeshellarg($tmpPath) + . ' -resize ' . $options->values['swidth'] + . $crop + . ' ' . escapeshellarg($img->getPath()); + Executor::run($convertcmd); + //var_dump($convertcmd);die(); + unlink($tmpPath); + } +} +?>