承接 minicodemonkey/portrayal 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

minicodemonkey/portrayal

最新稳定版本:v2.2.0

Composer 安装命令:

composer require minicodemonkey/portrayal

包简介

Simple, self-contained library allows you to capture screenshots of websites using PhantomJS.

README 文档

README

Build Status

Portrayal

This simple, self-contained library allows you to capture screenshots using PhantomJS.

Installation

You can install this package through Composer. Edit your project's composer.json file to require minicodemonkey/portrayal.

"require": {
	"minicodemonkey/portrayal": "~2.0"
}

You will also need to add post-install and post-update scripts to composer.json as well as a config entry to set up the phantomjs binary dependency:

"config": {
    "bin-dir": "bin"
},
"scripts": {
    "post-install-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ],
    "post-update-cmd": [
        "PhantomInstaller\\Installer::installPhantomJS"
    ]
}

Now run composer update from the terminal, and you're good to go!

For more information, check out jakoch/phantomjs-installer

Usage

$capture = new \Portrayal\Capture;
$filename = $capture->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

// $filename = /var/folders/6_/htvcfzcd4cb_w9z6bgpmnx5h0000gn/T/d0582362c2ffbf50ee119e504bb64fdc6bba5abd.png

Adjust timeout

The time in seconds to wait on the phantomjs process before giving up. The default timeout is 30s.

$capture = new \Portrayal\Capture;
$filename = $capture->setTimeout(10)
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Adjust rendering delay

The time in seconds to wait taking the screenshot after the webpage has loaded. The default value is 0.35s (350ms).

$capture = new \Portrayal\Capture;
$filename = $capture->setRenderDelay(200)
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Disable animations

This will inject a couple of scripts to disable CSS3 animations as well as jQuery animations. Useful for making sure that subsequent screenshots will have the same state.

$capture = new \Portrayal\Capture;
$filename = $capture->disableAnimations()
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Change user agent

This allows you to change the HTTP User-Agent header set by the phantomjs process.

$capture = new \Portrayal\Capture;
$filename = $capture->setUserAgent('MyScreenShotApp 1.0')
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Change browser viewport dimensions

This will change the browser viewport. Please note that this might not necessarily correspond to the exact dimensions of the screenshot. Please see https://github.com/ariya/phantomjs/issues/10619 for additional details.

$capture = new \Portrayal\Capture;
$filename = $capture->setViewPort($width = 320, $height = 480)
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

Specify a custom cookie jar

This will allow you to set specific cookies for the session, this is for example useful for retaining the cookie state across multiple requests.

$capture = new \Portrayal\Capture;
$filename = $capture->setCookiesFile('/tmp/cookies.txt')
    ->snap('https://github.com/minicodemonkey/Portrayal', sys_get_temp_dir());

统计信息

  • 总下载量: 9.35k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-08-30

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固