I have a site where I list many images from an external URL. The problem is that those images are huge and take up a lot of loading time. I would like to resize them from the URL, without downloading them to my server. Could you please help me out with a PHP script for this? Thanks!
Without downloading them, it is impossible to modify them. If you meant saving instead of downloading, that's a different thing and there are multiple options you can choose from (for example PHP built-in functions or ImageMagick).
Yup, I meant without saving them. They are different extensions so it is harder to display them in a smaller size. At least I don't know how to do that..
Here's a pretty good library to resize images - https://github.com/eventviva/php-image-resize Or you can use one of native PHP functions, such as http://php.net/manual/en/imagick.resizeimage.php or similar.
Other option which I think which you can experiment with resizing the images in the web pages. You can mention the size of the image in the HTML part which will squeeze the images to limited sizes.
While it may sound like a possible solution, I would strongly recommend not doing so. First of all, it's the worst possible way to resize image. Second, there will be many situations when this method won't work properly.
I used timthumb in the past, now they came up with a secure alternative: https://github.com/mindsharelabs/mthumb What it does is it crops images out and significantly reduces their kb sizes. You can adjust the height and width and depending on the images you won't even know they were cropped out. It can be used for both internal and external image links. To understand how it works, check out this page: https://www.binarymoon.co.uk/2010/08/timthumb/