Fix resizing & add logs

dev
gravel 1 year ago
parent 7738318ec9
commit 8258e76b5a
Signed by: gravel
GPG Key ID: C0538F3C906B308F

4
.gitignore vendored

@ -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

@ -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);
}

Loading…
Cancel
Save