gstjohn/thumbsnag
最新稳定版本:v1.0.1
Composer 安装命令:
composer require gstjohn/thumbsnag
包简介
Thumbsnag crawls an HTML document and finds imagery that best represents the given page.
README 文档
README
Thumbsnag crawls an HTML document and finds imagery that best represents the given page.
Example
use Thumbsnag\FastImageAnalyzer; use Thumbsnag\Thumbsnag; use Thumbsnag\UrlDocument; $url = 'http://simplegifts.co'; $html = file_get_contents($url); $document = new DOMDocument(); $document->loadHTML($html); $analyzer = new FastImageAnalyzer(new FastImage()); $thumbsnag = Thumbsnag::load(new UrlDocument($doc, $url), $analyzer); $images = $thumbsnag->process();
After inspection, $images will return something like:
Array ( [1] => Thumbsnag\Image Object ( [url:Thumbsnag\Image:private] => http://simplegifts.co/image1.jpg [height:Thumbsnag\Image:private] => 565 [width:Thumbsnag\Image:private] => 849 ) [2] => Thumbsnag\Image Object ( [url:Thumbsnag\Image:private] => http://simplegifts.co/image2.png [height:Thumbsnag\Image:private] => 450 [width:Thumbsnag\Image:private] => 1162 ) )
Configuration
Step 1: Install
Pull the package in through Composer.
"require": { "gstjohn/thumbsnag": "~1.0" }
Step 2: Configure (as necessary)
Thumbsnag::load() takes an array as its third parameter which overrides the default config. Available configuration options are:
-
min_area (default: 5000)
This option represents the minimum pixel area (width x height) required in order to be included in the result set.
-
ratio_threshold (default: 3.0)
This option represents the maximum ratio of width-to-height allowed in order to be included in the result set.
-
filename_filters (default: "sprite", "blank", and "spacer")
This option represents an array of words that must not be in the image file name in order to be included in the result set.
Credits
License
Thumbsnag is open-sourced software licensed under the MIT license.
统计信息
- 总下载量: 29
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 11
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-03-13