From 93c02436fb0b7afffb6c62547385757b1a1b57f8 Mon Sep 17 00:00:00 2001 From: ilotterytea Date: Tue, 29 Apr 2025 02:06:11 +0500 Subject: feat: download user's profile banner --- src/config.php | 3 ++- src/images.php | 12 +++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/config.php b/src/config.php index 9191bb9..7c740d1 100644 --- a/src/config.php +++ b/src/config.php @@ -17,4 +17,5 @@ define("ANONYMOUS_DEFAULT_NAME", "chud"); // ACCOUNTS define("ACCOUNT_USERNAME_REGEX", "/^[A-Za-z0-9_]+$/"); define("ACCOUNT_USERNAME_MAX_LENGTH", 20); -define("ACCOUNT_PFP_MAX_SIZE", [128, 128]); \ No newline at end of file +define("ACCOUNT_PFP_MAX_SIZE", [128, 128]); +define("ACCOUNT_BANNER_MAX_SIZE", [1920, 1080]); \ No newline at end of file diff --git a/src/images.php b/src/images.php index 970fa99..d57794f 100644 --- a/src/images.php +++ b/src/images.php @@ -1,5 +1,5 @@ resizeImage($new_width, $new_height, Imagick::FILTER_TRIANGLE, 1); $frame->setImagePage($new_width, $new_height, 0, 0); } @@ -41,6 +46,11 @@ function resize_image(string $src_path, string $dst_path, int $max_width, int $m $new_width = (int) ($width * $ratio); $new_height = (int) ($height * $ratio); + if ($stretch) { + $new_width = $max_width; + $new_height = $max_height; + } + $imagick->resizeImage($new_width, $new_height, Imagick::FILTER_TRIANGLE, 1); $imagick->writeImage("$dst_path$format"); } -- cgit v1.2.3