farmani / remote-image-info
在不下载整个文件的情况下获取图像信息
v0.1.2
2015-08-10 05:05 UTC
Requires
- php: >=5.4.0
- ext-curl: *
This package is not auto-updated.
Last update: 2024-09-14 17:11:12 UTC
README
FastImage通过尽可能少地获取所需内容,根据Stephen Sykes出色的Ruby实现,通过uri获取远程图像文件的尺寸或文件类型。
用法
<?php require 'RemoteImageInfo.php'; $uri = "http://farm9.staticflickr.com/8151/7357346052_54b8944f23_b.jpg"; // loading image into constructor $image = new RemoteImageInfo($uri); if($image->checkLoad()) { list($width, $height) = $image->getSize(); echo "dimensions: " . $width . "x" . $height; } // or, create an instance and use the 'load' method $image = new RemoteImageInfo(); $image->load($uri); if($image->checkLoad()) { $type = $image->getType(); echo "filetype: " . $type; }
参考
- https://github.com/sdsykes/fastimage
- http://pennysmalls.com/find-jpeg-dimensions-fast-in-pure-ruby-no-ima
- http://snippets.dzone.com/posts/show/805
- http://www.anttikupila.com/flash/getting-jpg-dimensions-with-as3-without-loading-the-entire-file/
- http://imagesize.rubyforge.org/
许可
RemoteImageInfo在MIT许可下发布。它简单易懂,对软件的用途几乎没有限制。更多信息
下载
可以从GitHub下载版本。