diff --git a/src/applications/files/transform/PhabricatorFileImageTransform.php b/src/applications/files/transform/PhabricatorFileImageTransform.php --- a/src/applications/files/transform/PhabricatorFileImageTransform.php +++ b/src/applications/files/transform/PhabricatorFileImageTransform.php @@ -7,6 +7,8 @@ private $image; private $imageX; private $imageY; + const MAX_TRANSFORM_WIDTH = 4096; /* int */ + const MAX_TRANSFORM_HEIGHT = 4096; /* int */ /** * Get an estimate of the transformed dimensions of a file. @@ -334,7 +336,7 @@ 'Unable to determine image width and height with getimagesize().')); } - $max_pixels = (4096 * 4096); + $max_pixels = (self::MAX_TRANSFORM_WIDTH * self::MAX_TRANSFORM_HEIGHT); $img_pixels = ($width * $height); if ($img_pixels > $max_pixels) { @@ -365,6 +367,14 @@ return $this->image; } + /** + * Get maximum supported image dimensions in pixels for transforming + * @return array Maximum width and height + */ + public static function getMaxTransformDimensions() { + return array(self::MAX_TRANSFORM_WIDTH, self::MAX_TRANSFORM_HEIGHT); + } + private function shouldUseImagemagick() { if (!PhabricatorEnv::getEnvConfig('files.enable-imagemagick')) { return false; diff --git a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php --- a/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php +++ b/src/applications/people/controller/PhabricatorPeopleProfilePictureController.php @@ -36,6 +36,11 @@ $e_file = true; $errors = array(); + $max_image_dimensions = + PhabricatorFileImageTransform::getMaxTransformDimensions(); + $max_image_dimensions_message = pht('Maximum image dimensions: %s pixels.', + implode(mb_chr(215), $max_image_dimensions)); + if ($request->isFormPost()) { $phid = $request->getStr('phid'); $is_default = false; @@ -254,7 +259,8 @@ ->setName('picture') ->setLabel(pht('Upload Picture')) ->setError($e_file) - ->setCaption($supported_formats_message)) + ->setCaption($supported_formats_message.' '. + $max_image_dimensions_message)) ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton($done_uri) diff --git a/src/applications/project/controller/PhabricatorProjectEditPictureController.php b/src/applications/project/controller/PhabricatorProjectEditPictureController.php --- a/src/applications/project/controller/PhabricatorProjectEditPictureController.php +++ b/src/applications/project/controller/PhabricatorProjectEditPictureController.php @@ -35,6 +35,11 @@ $e_file = true; $errors = array(); + $max_image_dimensions = + PhabricatorFileImageTransform::getMaxTransformDimensions(); + $max_image_dimensions_message = pht('Maximum image dimensions: %s pixels.', + implode(mb_chr(215), $max_image_dimensions)); + if ($request->isFormPost()) { $phid = $request->getStr('phid'); $is_default = false; @@ -261,7 +266,8 @@ ->setName('picture') ->setLabel(pht('Upload Picture')) ->setError($e_file) - ->setCaption($supported_formats_message)) + ->setCaption($supported_formats_message.' '. + $max_image_dimensions_message)) ->appendChild( id(new AphrontFormSubmitControl()) ->addCancelButton($manage_uri)