-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #663 from gemini-testing/HERMIONE-285.migrate_from…
…_pngimg fix: migrate png-img -> sharp
- Loading branch information
Showing
24 changed files
with
1,057 additions
and
857 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,27 @@ | ||
'use strict'; | ||
|
||
exports.isFullPage = (image, page, screenshotMode) => { | ||
exports.isFullPage = (imageArea, page, screenshotMode) => { | ||
switch (screenshotMode) { | ||
case 'fullpage': return true; | ||
case 'viewport': return false; | ||
case 'auto': return compareDimensions(image, page); | ||
case 'auto': return compareDimensions(imageArea, page); | ||
} | ||
}; | ||
|
||
/** | ||
* @param {Image} image - PngImg wrapper | ||
* @param {Object} imageArea - area | ||
* @param {number} imageArea.left - left offset | ||
* @param {number} imageArea.top - top offset | ||
* @param {number} imageArea.width - area width | ||
* @param {number} imageArea.height - area height | ||
* @param {Object} page - capture meta information object | ||
* @returns {boolean} | ||
* @private | ||
*/ | ||
function compareDimensions(image, page) { | ||
function compareDimensions(imageArea, page) { | ||
const pixelRatio = page.pixelRatio; | ||
const documentWidth = page.documentWidth * pixelRatio; | ||
const documentHeight = page.documentHeight * pixelRatio; | ||
const imageSize = image.getSize(); | ||
|
||
return imageSize.height >= documentHeight && imageSize.width >= documentWidth; | ||
return imageArea.height >= documentHeight && imageArea.width >= documentWidth; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.