PHP Class Screen\Capture

Author: André Filipe
Show file Open project: microweber/screen

Public Properties

Property Type Description
$binPath string Bin directory, should contain the phantomjs file, otherwise it won't work
$jobs Screen\Location\Jobs Jobs directory, directory for temporary files to be written and executed with phantomjs
$output Screen\Location\Output Base directory to save the output files
$templatePath string Template directory, directory in which will be the js templates files to execute

Protected Properties

Property Type Description
$backgroundColor string Default body background color is white
$clipHeight integer Height of the page to clip
$clipWidth integer Width of the page to clip
$height integer Height of the page to render
$imageLocation string Location where the file was written to
$imageType Screen\Image\Types\Type Image Type, default is jpeg
$includedJsScripts array List of included JS scripts
$includedJsSnippets array List of included JS snippets
$options array List of options which will be passed to phantomjs
$timeout integer Sets the timeout period
$url string URL to capture the screen of
$userAgentString string User Agent String used on the page request
$width integer Width of the page to render

Public Methods

Method Description
__construct ( $url = null ) Capture constructor.
getImageLocation ( ) : string Returns the location where the screenshot file was written
getImageType ( ) : Type Returns the image type instance
includeJs ( string | URL $script ) : Capture Adds a JS script or snippet to the screen shot script
save ( string $imageLocation, boolean $deleteFileIfExists = true ) : boolean Saves the screenshot to the requested location
setBackgroundColor ( string $backgroundColor ) : Capture Sets the page body background color
setBinPath ( $binPath ) Sets the path to PhantomJS binary, example: "/usr/bin"
setClipHeight ( integer $clipHeight ) : Capture Sets the height to clip
setClipWidth ( integer $clipWidth ) : Capture Sets the width to clip
setHeight ( integer $height ) : Capture Sets the page height
setImageType ( string $type ) : Capture Sets the image type
setOptions ( array $options ) Sets the options which will be passed to phantomjs
setTimeout ( integer $timeout ) : Capture Sets the timeout period
setUrl ( string $url ) Sets the url to screenshot
setUserAgentString ( string $userAgentString ) : Capture Sets the User Agent String to be used on the page request
setWidth ( integer $width ) : Capture Sets the page width

Private Methods

Method Description
getOptionsString ( ) : string
getTemplateResult ( string $templateName, array $args ) : string

Method Details

__construct() public method

Capture constructor.
public __construct ( $url = null )

getImageLocation() public method

Returns the location where the screenshot file was written
public getImageLocation ( ) : string
return string

getImageType() public method

Returns the image type instance
public getImageType ( ) : Type
return Screen\Image\Types\Type

includeJs() public method

Adds a JS script or snippet to the screen shot script
public includeJs ( string | URL $script ) : Capture
$script string | URL Script to include
return Capture

save() public method

Saves the screenshot to the requested location
public save ( string $imageLocation, boolean $deleteFileIfExists = true ) : boolean
$imageLocation string Image Location
$deleteFileIfExists boolean True to delete the file if it exists
return boolean

setBackgroundColor() public method

Sets the page body background color
public setBackgroundColor ( string $backgroundColor ) : Capture
$backgroundColor string Background Color
return Capture

setBinPath() public method

Sets the path to PhantomJS binary, example: "/usr/bin"
public setBinPath ( $binPath )

setClipHeight() public method

Sets the height to clip
public setClipHeight ( integer $clipHeight ) : Capture
$clipHeight integer Page clip height
return Capture

setClipWidth() public method

Sets the width to clip
public setClipWidth ( integer $clipWidth ) : Capture
$clipWidth integer Page clip width
return Capture

setHeight() public method

Sets the page height
public setHeight ( integer $height ) : Capture
$height integer Page Height
return Capture

setImageType() public method

Sets the image type
public setImageType ( string $type ) : Capture
$type string 'jpg', 'png', etc...
return Capture

setOptions() public method

Sets the options which will be passed to phantomjs
public setOptions ( array $options )
$options array

setTimeout() public method

Sets the timeout period
public setTimeout ( integer $timeout ) : Capture
$timeout integer Timeout period
return Capture

setUrl() public method

Sets the url to screenshot
public setUrl ( string $url )
$url string URL

setUserAgentString() public method

Sets the User Agent String to be used on the page request
public setUserAgentString ( string $userAgentString ) : Capture
$userAgentString string User Agent String
return Capture

setWidth() public method

Sets the page width
public setWidth ( integer $width ) : Capture
$width integer Page Width
return Capture

Property Details

$backgroundColor protected property

Default body background color is white
protected string $backgroundColor
return string

$binPath public property

Bin directory, should contain the phantomjs file, otherwise it won't work
public string $binPath
return string

$clipHeight protected property

Height of the page to clip
protected int $clipHeight
return integer

$clipWidth protected property

Width of the page to clip
protected int $clipWidth
return integer

$height protected property

Height of the page to render
protected int $height
return integer

$imageLocation protected property

Location where the file was written to
protected string $imageLocation
return string

$imageType protected property

Image Type, default is jpeg
protected Type,Screen\Image\Types $imageType
return Screen\Image\Types\Type

$includedJsScripts protected property

List of included JS scripts
protected array $includedJsScripts
return array

$includedJsSnippets protected property

List of included JS snippets
protected array $includedJsSnippets
return array

$jobs public property

Jobs directory, directory for temporary files to be written and executed with phantomjs
public Jobs,Screen\Location $jobs
return Screen\Location\Jobs

$options protected property

List of options which will be passed to phantomjs
protected array $options
return array

$output public property

Base directory to save the output files
public Output,Screen\Location $output
return Screen\Location\Output

$templatePath public property

Template directory, directory in which will be the js templates files to execute
public string $templatePath
return string

$timeout protected property

Sets the timeout period
protected int $timeout
return integer

$url protected property

URL to capture the screen of
protected string $url
return string

$userAgentString protected property

User Agent String used on the page request
protected string $userAgentString
return string

$width protected property

Width of the page to render
protected int $width
return integer