summaryrefslogtreecommitdiff
path: root/public/upload.php
diff options
context:
space:
mode:
authorilotterytea <iltsu@alright.party>2025-10-01 22:19:15 +0500
committerilotterytea <iltsu@alright.party>2025-10-01 22:19:15 +0500
commit7022695c057d2d3cb526db92de2ffdf54ba8d10e (patch)
treecbd251b9beec397607e5dda6895806ebe4fbefa3 /public/upload.php
parent21c125471b96176bbee0ea8cb8e3ef3b708eb7eb (diff)
feat: remove letterboxing from videos
Diffstat (limited to 'public/upload.php')
-rw-r--r--public/upload.php14
1 files changed, 14 insertions, 0 deletions
diff --git a/public/upload.php b/public/upload.php
index 123c30a..bfa1990 100644
--- a/public/upload.php
+++ b/public/upload.php
@@ -200,6 +200,20 @@ try {
throw new RuntimeException('This file is not allowed for upload.' . (isset($row['reason']) ? ' Reason: ' . $row['reason'] : ''));
}
+ // remove letterbox
+ $remove_letterbox = FILE_REMOVE_LETTERBOXES && boolval($_POST['remove_letterbox'] ?? '0');
+ if ($remove_letterbox && str_starts_with($file_data['mime'], 'video/')) {
+ $output_path = $file_path;
+ $input_path = FILE_UPLOAD_DIRECTORY . sprintf('/%s.temporary.%s', $file_id, $file_data['extension']);
+ rename($output_path, $input_path);
+ if (!remove_video_letterbox($input_path, $output_path)) {
+ rename($input_path, $output_path);
+ delete_file($file_id, $file_data['extension']);
+ throw new RuntimeException('Failed to remove letterbox from the video');
+ }
+ unlink($input_path);
+ }
+
$file_data['size'] = filesize($file_path);
if (FILE_THUMBNAILS && !is_dir(FILE_THUMBNAIL_DIRECTORY) && !mkdir(FILE_THUMBNAIL_DIRECTORY, 0777, true)) {