Getimagesize is very expensive function to get the image details, it will slow the process. I will not recommend it to use on loop.