I'm currently trying to set up a html gallery with a php script that automaticaly resizes them an puts them into the gallery. My problem now is that there are around 30 pictures and:
- It takes forever to load the site.
- The images don't load properly. The string thats looks like binary? I don't know
Thats the only php code I'm running:
<?php
$directory = "images/gallery/feet";
$images = glob($directory . "/*.jpg");
foreach ($images as $image) {
//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);
echo "<div class=\"carousel-item\">";
echo "<img class=\"d-block w-100\" src=\"${thumb}\" />";
echo "</div>";
}
?>
Do you know what I can do?