Very slow server respond times when creating thumbnails

I got the problem that my localhost got really slow respond times and I think I hunted the problem down to the thumbnail creation process. At the moment I need ~12 seconds for every page refresh which drives me crazy.

First I thought it is a problem with xampp or something but I guess it is my code. I am generating a simple image gallery with ~15 images and create smaller thumbnails for each image and a bigger version for when you click on it. If I comment out this code the loading times go from ~12 down to ~3-4 seconds (which would be respectable but still not very fast)

<?php 
	$count = 0;
	$images = $module->images()->sortBy('sort', 'asc'); 
?>

<?php foreach($images as $image): ?>

       <?php $thumb = thumb($image, array('width' => 1300, 'quality' => 80, 'crop' => false), true); ?>
	<?php ++$count; ?>

	<figure class="4u<?php ecco($count % 3 == 0, '$', '') ?> 6u<?php ecco($count % 2 == 0, '$', '') ?>(narrow) 12u(mobile)">
	   <a href="<?php echo $thumb->url() ?>" data-size="<?php echo $thumb->width() . 'x' . $thumb->height() ?>">
              <img data-src="<?php echo thumb($image, array('width' => 400, 'height' => 266, 'quality' => 80, 'crop' => true), false) ?>" alt="<?php echo $image->caption(); ?>" />
	   </a>
	   <figcaption><?php echo $image->caption(); ?></figcaption>
	</figure>

<?php endforeach ?>

Now I question myself why this slows down my page (the server respond time) so much? Doesn’t kirby recognize when the thumbnails are already created and will just serve them? How could I improve my code so that it’s faster?

Any ideas of what common pitfalls for performance issues can be? I also often need something like $pages->find('somePage'); is this a problem or is there a better way to serve a page that you often need (instead of searching it)?

@Andi-Lo:
You use the Kirby-default-thumbs driver “gd”?
If not, change this to the default, because the “im” driver does not exist on Windows-XAMPP.

Does the \thumbs directory exist?

Good luck!

using c::set('thumbs.driver','gd') sadly does not do the trick :frowning:

The thumb folder exists and all thumbs are already generated. Also its just appearing to be slow on my localhost and not online. When I visit the page on my dev server everything responds fine. Locally it just appears that the browser reacts with very slow "waiting for localhost… " . I tried to remove any addons and also tried different browsers (even different pc’s). Further I tried to use php -S localhost:8080 instead of xampp but without success.

The gd driver is the default driver, anyway. Once the thumbs are generated, the performance should indeed improve, because existing thumbs should not be not generated again.