summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-04-27 22:24:05 +0500
committerilotterytea <iltsu@alright.party>2025-04-27 22:24:05 +0500
commit067348835299febed3080ab61ffca365cd07743f (patch)
tree5abe32ea3837e425612f3b6d939ee06f7baff438 /src
parent69355b508f0fd012b08c773b950e7b0be96c9185 (diff)
feat: change username and pfp
Diffstat (limited to 'src')
-rw-r--r--src/config.php7
-rw-r--r--src/images.php12
2 files changed, 14 insertions, 5 deletions
diff --git a/src/config.php b/src/config.php
index 3f4c52d..9191bb9 100644
--- a/src/config.php
+++ b/src/config.php
@@ -12,4 +12,9 @@ define("RATING_NAMES", [
// UPLOADS
define("ANONYMOUS_UPLOAD", false);
-define("ANONYMOUS_DEFAULT_NAME", "chud"); \ No newline at end of file
+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
diff --git a/src/images.php b/src/images.php
index fea1825..970fa99 100644
--- a/src/images.php
+++ b/src/images.php
@@ -1,5 +1,5 @@
<?php
-function resize_image(string $src_path, string $dst_path, int $max_width, int $max_height): string|null
+function resize_image(string $src_path, string $dst_path, int $max_width, int $max_height, bool $set_format = true): string|null
{
if ($src_path == "" || !getimagesize($src_path)) {
return json_encode([
@@ -12,7 +12,11 @@ function resize_image(string $src_path, string $dst_path, int $max_width, int $m
$imagick = new Imagick();
$imagick->readImage($src_path);
- $format = strtolower($imagick->getImageFormat());
+ $format = "." . strtolower($imagick->getImageFormat());
+
+ if (!$set_format) {
+ $format = "";
+ }
if ($imagick->getNumberImages() > 1) {
$imagick = $imagick->coalesceImages();
@@ -29,7 +33,7 @@ function resize_image(string $src_path, string $dst_path, int $max_width, int $m
}
$imagick = $imagick->deconstructImages();
- $imagick->writeImages("$dst_path.$format", true);
+ $imagick->writeImages("$dst_path$format", true);
} else {
$width = $imagick->getImageWidth();
$height = $imagick->getImageHeight();
@@ -38,7 +42,7 @@ function resize_image(string $src_path, string $dst_path, int $max_width, int $m
$new_height = (int) ($height * $ratio);
$imagick->resizeImage($new_width, $new_height, Imagick::FILTER_TRIANGLE, 1);
- $imagick->writeImage("$dst_path.$format");
+ $imagick->writeImage("$dst_path$format");
}
$imagick->clear();