Skip to content

Commit

Permalink
transparent background fix
Browse files Browse the repository at this point in the history
  • Loading branch information
maaaaz committed Apr 23, 2015
1 parent 2de934d commit 6d70381
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ Requirements

Changelog
---------
* version 1.6 - 04/23/2015: Transparent background fix
* version 1.5 - 01/11/2015: Cookie and custom HTTP header support
* version 1.4 - 10/12/2014: url-to-image phantomjs script integration + few bugs corrected
* version 1.3 - 08/05/2014: Windows support + few bugs corrected
Expand Down
7 changes: 6 additions & 1 deletion webscreenshot.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#
# You should have received a copy of the GNU Lesser General Public License
# along with webscreenshot. If not, see <http://www.gnu.org/licenses/>.
**/
***/

var Page = (function(custom_headers) {
var opts = {
Expand Down Expand Up @@ -74,6 +74,11 @@ var Page = (function(custom_headers) {
};

function renderAndExit() {
// Trick to avoid transparent background
page.evaluate(function() {
document.body.bgColor = 'white';
});

page.render(opts.file);
phantom.exit(0);
}
Expand Down
8 changes: 4 additions & 4 deletions webscreenshot.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
options_definition = [option_0, option_1, option_2, option_3, option_4, option_5, option_6, option_7, option_8, option_9, option_10]

# Script version
VERSION = '1.5'
VERSION = '1.6'

# phantomjs binary, hoping to find it in a $PATH directory
## Be free to change it to your own full-path location
Expand Down Expand Up @@ -116,7 +116,7 @@ def shell_exec(url, command, options):
try :
p = subprocess.Popen(shlex.split(command), shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)

# phantomjs timeout
# Phantomjs timeout
while p.poll() is None:
time.sleep(0.1)
now = datetime.datetime.now()
Expand All @@ -133,13 +133,13 @@ def shell_exec(url, command, options):

retval = p.poll()
if retval != SHELL_EXECUTION_OK:
# phantomjs general error
# Phantomjs general error
logger_url.error("Shell command PID %s returned an abnormal error code: '%s'" % (p.pid,retval))
logger_url.error("Screenshot somehow failed\n")
return SHELL_EXECUTION_ERROR

else:
# phantomjs ok
# Phantomjs ok
logger_url.debug("Shell command PID %s ended normally" % p.pid)
logger_url.info("Screenshot OK\n")
return SHELL_EXECUTION_OK
Expand Down

0 comments on commit 6d70381

Please sign in to comment.