revert to not using Imagick
All checks were successful
/ docker (push) Successful in 29s

This commit is contained in:
Lee 2023-07-08 00:51:33 +01:00
parent 9109639908
commit d6f346200a
2 changed files with 6 additions and 21 deletions

@ -3,7 +3,7 @@ FROM alpine:3.18.2
# Install dependencies
RUN apk update && \
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/*
# Set up nginx

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