使用Curl获取图像尺寸 [英] Get image dimensions with Curl

查看:96
本文介绍了使用Curl获取图像尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个远程图像的height * width。

I would like the height*width of a remote image. Could that be done with Curl, and if so how?

推荐答案

图像的高度和宽度是图像文件内的属性并且您需要撤消该文件才能访问它们。根据图像格式,此属性将位于图像元数据的不同位置。您可以使用getimagesize来做到这一点,但是请记住,您实际上检索的是完整的图片,这将影响您的操作的性能。

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.

图像,你可以尝试像开始fecthing的图像到你的服务器,一旦你开始接收数据,并知道图像的格式,等待,直到你从图像中看到足够的高度和宽度信息,并停止转让。你很可能需要自己做这项工作,因为图像库和API中的内置函数可能会期望一个完整的图像正常工作。

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.

这篇关于使用Curl获取图像尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆