Migrate to Alpine #5

Merged
Fascinated merged 21 commits from development into master 2023-07-07 23:54:10 +00:00
2 changed files with 6 additions and 21 deletions
Showing only changes of commit d6f346200a - Show all commits

@ -3,7 +3,7 @@ FROM alpine:3.18.2
# Install dependencies # Install dependencies
RUN apk update && \ RUN apk update && \
apk upgrade && \ apk upgrade && \
apk add --no-cache nginx php81 php81-fpm php81-pecl-imagick && \ apk add --no-cache nginx php81 php81-fpm php81-gd && \
rm -rf /var/cache/apk/* rm -rf /var/cache/apk/*
# Set up nginx # Set up nginx

@ -162,28 +162,13 @@ try {
// Check the file type and size // Check the file type and size
if ($shouldConvertToWebp && in_array($fileType, ["png", "jpeg", "jpg"]) && $_FILES["sharex"]["size"] > $webpThreadhold) { if ($shouldConvertToWebp && in_array($fileType, ["png", "jpeg", "jpg"]) && $_FILES["sharex"]["size"] > $webpThreadhold) {
// Create an Imagick object from the uploaded file $image = imagecreatefromstring(file_get_contents($_FILES["sharex"]["tmp_name"]));
$image = new Imagick($_FILES["sharex"]["tmp_name"]);
// Convert the image to WebP
$image->setImageFormat("webp");
$image->setImageCompressionQuality($webpQuality);
// Set the output filename
$webp_file = pathinfo($finalName, PATHINFO_FILENAME) . ".webp"; $webp_file = pathinfo($finalName, PATHINFO_FILENAME) . ".webp";
imagewebp($image, $webp_file, 90); // Convert the image and save it
// Save the converted image imagedestroy($image); // Free up memory
$image->writeImage($webp_file);
// Free up memory
$image->clear();
$image->destroy();
$fileSize = filesize($webp_file); // Update the file size
// Update the final filename
$finalName = $webp_file; $finalName = $webp_file;
$needsToBeSaved = false; $shouldSave = false;
$fileSize = filesize($webp_file); // Update the file size
} }
if ($needsToBeSaved) { // Save the file if it has not been saved yet if ($needsToBeSaved) { // Save the file if it has not been saved yet