cwplus / web-thumbnail
Webthumbnail 模块是一个 ZF2 模块,可以帮助您从您的网站或另一个网站生成屏幕截图,基于 webthumbnail.org API
dev-master
2014-03-19 00:29 UTC
Requires
- php: >=5.3.3
- zendframework/zendframework: >=2.1.0
This package is not auto-updated.
Last update: 2024-09-24 05:30:33 UTC
README
此模块 ZF2 将帮助您根据 webthumbnail.org API 生成网站截图
安装
使用 composer
-
将以下内容添加到您的
composer.json"require": { "cwplus/web-thumbnail": "dev-master" }
-
现在运行以下命令让 composer 下载 MvlabsSnappy:
$ php composer.phar update
或者直接克隆仓库
# Install ZF2 Module
git clone https://github.com/cwplus/web-thumbnail.git vendor/cwplus/web-thumbnail
安装后
-
在您的
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 构建