Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/transform/PhabricatorFileImageTransform.php
Show First 20 Lines • Show All 113 Lines • ▼ Show 20 Lines | abstract class PhabricatorFileImageTransform extends PhabricatorFileTransform { | ||||
protected function applyImagemagick(array $argv) { | protected function applyImagemagick(array $argv) { | ||||
$tmp = new TempFile(); | $tmp = new TempFile(); | ||||
Filesystem::writeFile($tmp, $this->getData()); | Filesystem::writeFile($tmp, $this->getData()); | ||||
$out = new TempFile(); | $out = new TempFile(); | ||||
$future = new ExecFuture('convert %s %Ls %s', $tmp, $argv, $out); | $future = new ExecFuture('convert %s %Ls %s', $tmp, $argv, $out); | ||||
// Don't spend more than 10 seconds resizing; just fail if it takes longer | // Don't spend more than 60 seconds resizing; just fail if it takes longer | ||||
// than that. | // than that. | ||||
epriestley: Sometimes I'll sneakly rewrite these as "more than a short time resizing..." or similar to… | |||||
$future->setTimeout(10)->resolvex(); | $future->setTimeout(60)->resolvex(); | ||||
Not Done Inline ActionsChange this to 60. epriestley: Change this to 60. | |||||
$data = Filesystem::readFile($out); | $data = Filesystem::readFile($out); | ||||
return $this->newFileFromData($data); | return $this->newFileFromData($data); | ||||
} | } | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 121 Lines • ▼ Show 20 Lines | abstract class PhabricatorFileImageTransform extends PhabricatorFileTransform { | ||||
*/ | */ | ||||
protected function getData() { | protected function getData() { | ||||
if ($this->data !== null) { | if ($this->data !== null) { | ||||
return $this->data; | return $this->data; | ||||
} | } | ||||
$file = $this->file; | $file = $this->file; | ||||
$max_size = (1024 * 1024 * 4); | $max_size = (1024 * 1024 * 16); | ||||
$img_size = $file->getByteSize(); | $img_size = $file->getByteSize(); | ||||
if ($img_size > $max_size) { | if ($img_size > $max_size) { | ||||
throw new Exception( | throw new Exception( | ||||
pht( | pht( | ||||
'This image is too large to transform. The transform limit is %s '. | 'This image is too large to transform. The transform limit is %s '. | ||||
'bytes, but the image size is %s bytes.', | 'bytes, but the image size is %s bytes.', | ||||
new PhutilNumber($max_size), | new PhutilNumber($max_size), | ||||
new PhutilNumber($img_size))); | new PhutilNumber($img_size))); | ||||
▲ Show 20 Lines • Show All 112 Lines • Show Last 20 Lines |
Sometimes I'll sneakly rewrite these as "more than a short time resizing..." or similar to avoid the sort of soft DRY issue, but then I keep writing the constants anyway.