i am developing a test/learning app. i wonder how can i test if an image from another site/domain … i broke up my validation logic to the following
- exists
- is an image
- is of valid type
- is of a specific dimensions
- is below a max size – say i want the image to load quickly. tho the hosting resource is not mine.
getimagesize()can do all but the last of your points. For that you can usefilesize(). Forfilesize()you’ll have to actually download it though, but seeing asgetimagesize()also requires that, you can just save it to a temporary file. You can usetempnam()to get a temporary file that doesn’t conflict with others.