cwplus/web-thumbnail

Webthumbnail 模块是一个 ZF2 模块,可以帮助您从您的网站或另一个网站生成屏幕截图,基于 webthumbnail.org API

安装: 73

依赖: 0

建议者: 0

安全: 0

星级: 2

关注者: 1

分支: 0

公开问题: 0

类型:zf2-module

dev-master 2014-03-19 00:29 UTC

This package is not auto-updated.

Last update: 2024-09-24 05:30:33 UTC


README

此模块 ZF2 将帮助您根据 webthumbnail.org API 生成网站截图

安装

使用 composer

  1. 将以下内容添加到您的 composer.json

    "require": {
        "cwplus/web-thumbnail": "dev-master"
    }
  2. 现在运行以下命令让 composer 下载 MvlabsSnappy:

    $ php composer.phar update

或者直接克隆仓库

# Install ZF2 Module
git clone https://github.com/cwplus/web-thumbnail.git vendor/cwplus/web-thumbnail

安装后

  1. 在您的 application.config.php 文件中启用它。

    <?php
    return array(
        'modules' => array(
            // ...
            'Webthumbnail',            
        ),
        // ...
    );

配置

安装 Webthumbnail 后,将 ./vendor/cwplus/Webthumbnail/config/webthumbnail.local.php.dist 复制到 ./config/autoload/webthumbnail.local.php,并更改二进制路径以及保存网页缩略图的路径。

# /config/autoload/webthumbnail.local.php
<?php
return array(
    'webthumbnail'=>array(
        'path'=> './public/files/site/',
    )
);

使用方法

该模块注册了一个服务:WebthumbnailService

调用 webthumbnail 服务

 $WebthumbnailService = $this->serviceLocator->get('WebthumbnailService')->setUrl('http://www.creationwebplus.be');

如果您想更改保存网站截图的文件夹

 $WebthumbnailService = WebthumbnailService->setPath('./public/files/site/');

如果您想声明创建的图像的宽度和高度:( 100 < 宽度 < 500; 100 < 高度 < 500 )

宽度

$WebthumbnailService = WebthumbnailService->setWidth(250);

高度

$WebthumbnailService = WebthumbnailService->setHeight(250);

如果您想声明图像格式(支持的格式:jpg,png, 或 gif)

$WebthumbnailService = WebthumbnailService->setFormat('png');

如果您想声明图像格式(支持的格式:jpg,png, 或 gif)

$WebthumbnailService = WebthumbnailService->setFormat('png');

如果您想声明屏幕分辨率(1024, 1280, 1650 或 1920)

$WebthumbnailService = WebthumbnailService->setScreen(1024);

保存截图到路径

 $WebthumbnailService->captureToFile('screenshot.png');

从 URL 生成截图

 $WebthumbnailService->captureToOutput();

致谢

Webthumbnail 模块基于 webthumbnail.org API 构建