From 49f1c0ae7ba4abab7decac2aa7a20bb48ce7b253 Mon Sep 17 00:00:00 2001 From: gravel Date: Sat, 20 May 2023 23:19:11 +0200 Subject: [PATCH] Fix resizing & add logs --- .gitignore | 4 +++- php/utils/room-icons.php | 8 +++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 137bd49..7bb4750 100644 --- a/.gitignore +++ b/.gitignore @@ -4,12 +4,14 @@ output/*.html # Downloaded QR codes output/qr-codes +# Served icons +output/icons + # Server-side cache cache # Local tests .test -. # Kate *.kate-swp diff --git a/php/utils/room-icons.php b/php/utils/room-icons.php index 3d806cc..73a9e9d 100644 --- a/php/utils/room-icons.php +++ b/php/utils/room-icons.php @@ -16,8 +16,8 @@ * @param string $size Image dimensions. */ function room_icon_path_resized(string $room_id, string $size): string { - global $ROOM_ICONS_CACHE; - return "$ROOM_ICONS_CACHE/$room_id-$size"; + global $ROOM_ICONS; + return "$ROOM_ICONS/$room_id-$size"; } /** @@ -75,7 +75,9 @@ // Resize image $gd_image = imagecreatefromstring($icon_cached_contents); $gd_resized = imagescale($gd_image, $width, $height); - imagewebp($gd_resized, $icon_resized); + if (!imagewebp($gd_resized, $icon_resized)) { + log_info("Converting image for $room_id to $size failed"); + } return room_icon_path_relative($room_id, $size); }