Не пытайтесь запускать алгоритм изменения размера для каждого изображения при каждой загрузке страницы, это глупо дорогой процесс.
Запускайте его один раз - КОГДА-ЛИБО - для каждого файла и вставляйте миниатюры в дочерний каталог,
Затем просто дайте ссылку на файл миниатюрного изображения и позвольте вашему веб-серверу обрабатывать ваши заголовки, чтобы изображение правильно отображалось, вместо получения строки base64.
Что-то вроде
<?php
$directory = "images/gallery/feet";
$thmb_dir = $directory . "/thumbnail";
$images = glob($directory . "/*.jpg");
foreach ($images as $image) {
if (/*thumbnail doesn't already exist*/) {
//getting the image dimensions
list($width, $height) = getimagesize($image);
//saving the image into memory (for manipulation with GD Library)
$image = imagecreatefromjpeg($image);
// calculating the part of the image to use for thumbnail
if ($width > $height) {
$y = 0;
$x = ($width - $height) / 2;
$smallestSide = $height;
} else {
$x = 0;
$y = ($height - $width) / 2;
$smallestSide = $width;
}
$thumbSize = 500;
$thumb = imagecreatetruecolor($thumbSize, $thumbSize);
imagecopyresampled($thumb, $image, 0, 0, $x, $y, $thumbSize, $thumbSize, $smallestSide, $smallestSide);
imagejpeg($thumb, null, 100);
// Save this image w/ the same name in /thumbnails - I just made up this function name
saveThumb($thumb, $thmb_dir);
}
// Grab the thumbnail with the right name - another made-up function name
$thumb_link = getThumbLink($image)
echo "<div class=\"carousel-item\">";
echo "<img class=\"d-block w-100\" src=\"${thumb_link}\" />";
echo "</div>";
}
?>