gstjohn/thumbsnag 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 11
  • Watchers: 1
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-03-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固