Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 131c7aa

Browse files
Added the width and height parameters for the screenshot output type.
1 parent c5294a1 commit 131c7aa

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

‎ChangeLog.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Change Log
22

33
### 1.3.0
4+
- Added the `width` and `height` parameters for the `screenshot` output type.
45
- Added the `cache-lifespan` parameter that determines the cache duration.
56
- Added the ability to cache responses.
67

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,16 @@ http(s)://{app-address}/?url=https%3A%2F%2Fgithub.com&output=screenshot
5858

5959
#### file-type
6060

61-
When the `screenshot` parameter is set, the output file type can be set with the `file-type` parameter. Default: `jpg`.
61+
When `screenshot` is given for the `output` parameter, the output file type can be set with the `file-type` parameter. Default: `jpg`.
6262

6363
It accepts the following values: `pdf`, `png`, `jpg`, `jpeg`, `bmp`, `ppm`.
6464

65+
#### width
66+
When `screenshot` is given for the `output` parameter, `width` sets the screenshot image width.
67+
68+
#### height
69+
When `screenshot` is given for the `output` parameter, `height` sets the screenshot image height. Leave it unset to get full height.
70+
6571
###### Example
6672
```
6773
http(s)://{app-address}/?url=https%3A%2F%2Fgithub.com&output=screenshot&file-type=png

‎web/include/class/browser/ScreenCapture.php‎

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class ScreenCapture extends PhantomJSWrapper {
1111
'file_path' => '', // output file path
1212
'file_type' => 'jpg', // options: pdf, png, jpeg, bmp, ppm // gif causes an error
1313
'width' => 1200,
14-
'height' => 1800,
15-
14+
'height' => null, // null to get all the height
1615
);
1716

1817
public function get( $sURL ) {
@@ -28,8 +27,13 @@ public function get( $sURL ) {
2827
$request->setOutputFile( $_sOutputFilePath );
2928
$request->setFormat( $this->_aRequestArguments[ 'file_type' ] );
3029

31-
$request->setViewportSize( $_aRequestArguments[ 'width' ], $_aRequestArguments[ 'height' ] );
32-
// $request->setCaptureDimensions( $width, $height, $top, $left );
30+
$request->setViewportSize(
31+
$_aRequestArguments[ 'width' ],
32+
1800 // any number will show full height
33+
);
34+
if ( $_aRequestArguments[ 'height' ] ) {
35+
$request->setCaptureDimensions( $_aRequestArguments[ 'width' ], $_aRequestArguments[ 'height' ], 0, 0 );
36+
}
3337

3438
// @see https://github.com/jonnnnyw/php-phantomjs/issues/208
3539
if ( $this->_sUserAgent ) {

‎web/include/class/scraper/Scraper_screenshot.php‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ protected function _construct() {
1313
$this->_aClientArguments[ 'load-images' ] = isset( $_REQUEST[ 'load-images' ] ) && ! Utility::getBoolean( $_REQUEST[ 'load-images' ] )
1414
? false
1515
: true;
16+
17+
$this->_aRequestArguments[ 'width' ] = isset( $_REQUEST[ 'width' ] )
18+
? ( integer ) $_REQUEST[ 'width' ]
19+
: 1200;
20+
$this->_aRequestArguments[ 'height' ] = isset( $_REQUEST[ 'height' ] )
21+
? ( integer ) $_REQUEST[ 'height' ]
22+
: null; // to get all the height
1623

1724
}
1825

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /