Differential D18812 Diff 45134 src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
Changeset View
Changeset View
Standalone View
Standalone View
src/applications/files/builtin/PhabricatorFilesComposeAvatarBuiltinFile.php
Show First 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | final class PhabricatorFilesComposeAvatarBuiltinFile | ||||
} | } | ||||
public function loadBuiltinFileData() { | public function loadBuiltinFileData() { | ||||
return $this->composeImage( | return $this->composeImage( | ||||
$this->getColor(), $this->getIcon(), $this->getBorder()); | $this->getColor(), $this->getIcon(), $this->getBorder()); | ||||
} | } | ||||
private function composeImage($color, $image, $border) { | private function composeImage($color, $image, $border) { | ||||
// If we don't have the GD extension installed, just return a static | |||||
// default profile image rather than trying to compose a dynamic one. | |||||
if (!function_exists('imagecreatefromstring')) { | |||||
$root = dirname(phutil_get_library_root('phabricator')); | |||||
$default_path = $root.'/resources/builtin/profile.png'; | |||||
return Filesystem::readFile($default_path); | |||||
} | |||||
$color_const = hexdec(trim($color, '#')); | $color_const = hexdec(trim($color, '#')); | ||||
$true_border = self::rgba2gd($border); | $true_border = self::rgba2gd($border); | ||||
$image_map = self::getImageMap(); | $image_map = self::getImageMap(); | ||||
$data = Filesystem::readFile($image_map[$image]); | $data = Filesystem::readFile($image_map[$image]); | ||||
$img = imagecreatefromstring($data); | $img = imagecreatefromstring($data); | ||||
// 4 pixel border at 50x50, 32 pixel border at 400x400 | // 4 pixel border at 50x50, 32 pixel border at 400x400 | ||||
▲ Show 20 Lines • Show All 377 Lines • Show Last 20 Lines |