I would like the height*width of a remote image. Could that be done with Curl, and if so how?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The height and width of an image are attributes inside the image file and you need to retieve the file to be able to access them. Depending on the image format, this attributes will be in diferent places of the image metadata. You can do this with getimagesize, but bear in mind that you are actually retrieving the full image, which will affect the performance of your operation.
In the event of a large image, you can try something like start fecthing the image to your server and, as soon as you start receiving data and know the format of the image, wait until you receive enough from the image to look at the height and width information and stop the transfer. You will most likely need to do this job yourself, as image libraries and built in functions in APIs will probably expect a full image to work properly.
If by chance you control the server where the images are, you are better of writting a small script hosted in that server that given an image file identifier returns the height and width for that image.