I don’t know how piwigo works.
I use zenphoto which is mostly light weight… EXCEPT it can get nasty if you have large directories AND a theme that displays many at once re-sized AND you just uploaded them. What happens is it checks the image cache for resized thumbnails, finding none because they are new images imagemagick gets called for each to create the size needed for the theme, this is done as the first visitor to the album waits for a long slow load of the page. once that’s done once it’s cached as a file in an adjoining cache directory. When the next visitor comes the images are already re-sized making for a lighter faster load.
check and see if re-visiting a page has the same effect as a page with new images.