Page 1 of 1
Getimagesize random
Posted: Fri May 05, 2023 11:31 pm
by pierrepercee
Hello,
I have a problem with the Getimagesize() function used in a gallery module template.
Each time the gallery is loaded, only the sizes (width and height) of a few images are retrieved, sometimes all of them. It's completely random and not necessarily the same images. I obviously tried with different images from different sources
Code: Select all
<ul>
{foreach from=$images item=image}
{$imagesize=getimagesize($image->file)}
<li> name : {$image->file} <em>width :</em> {$imagesize[0]}- <em>height:</em> {$imagesize[1]} </li>
{/foreach}
</ul>
Ctrl+F5 gives randomly
I spent hours there and I admit I don't understand what's going on....

Re: Getimagesize random
Posted: Sat May 06, 2023 1:02 am
by DIGI3
getimagesize() is a php function, so perhaps you're running out of php memory? Check the php error log, and the admin log, to see if there's any clues. It could also be your host limiting the number of processes.
Re: Getimagesize random
Posted: Sat May 06, 2023 11:04 am
by pierrepercee
Thanks Digi3,
.
I have a failed to open stream error: connection refused.
I know it's a php function. I created a php file at the root of my site and a directory of images ( many).
Code: Select all
<?php
function walkDir($path = null) {
if(empty($path)) {
$d = new DirectoryIterator('./testqdima');
} else {
$d = new DirectoryIterator($path);
}
foreach($d as $f) {
if(
$f->isFile() &&
preg_match("/(\.gif|\.png|\.jpe?g)$/", $f->getFilename())
) {
list($w, $h) = getimagesize($f->getPathname());
echo "<p>".$f->getFilename() . " Dimensions: " . $w . ' ' . $h . "</p>";
} elseif($f->isDir() && $f->getFilename() != '.' && $f->getFilename() != '..') {
walkDir($f->getPathname());
}
}
}
walkDir();
?>
It works perfectly, all images are alway processed.
My client, despite my recommendation to reduce the images to 1200x X before sending, tried with 15mb images. Is it possible that the host has reduced resources on a particular directory ?
Re: Getimagesize random
Posted: Sat May 06, 2023 12:35 pm
by DIGI3
I haven't used the gallery module in a while, is $image->file the path or the url? If it's the latter, that could explain the difference between your function using the path and the gallery template. I'm just guessing at this point though, it's a bit outside my wheelhouse.
Re: Getimagesize random
Posted: Sun May 07, 2023 7:34 pm
by pierrepercee
Hello,
I asked the question on stackoverflow, it is indeed a problem with the host(against DDOS attack). I use Photoswipe which is probably the most advanced jquery module for gallery. I will try to ask the developer to add the width and height in the database.
I'm not sure...
