Git Product home page Git Product logo

webkit2png's Introduction

webkit2png

webkit2png is a command line tool for macOS that creates screenshots of webpages. For more info see the project homepage.

webkit2png's People

Contributors

aslakhellesoy avatar cowsandmilk avatar georgebrock avatar jamesscottbrown avatar jstcki avatar mhoffmeyerdc avatar norm avatar paulhammond avatar romac avatar scoates avatar seanhellwig avatar sophiebits avatar yuj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

webkit2png's Issues

Alert Confirmation

I love this piece of software, there is just one thing: I'm trying to create png from webpages containing Google Maps featuring geocode-request. Each time the page has loaded an alert pops up, asking for confirmation to track the browsers current location. Since I cannot confirm that dialog I wonder if there is some way to bypass the need to alert on geocoding requests. Safari and Chrome both have options in their GUI to override the alerts "for 1 day".

Images cropped incorrectly on retina displays

When using the --selector option, the results are great when I run webkit2png on a "normal" display (non-retina). However, when it's run on a retina display (I guess the main display setting is relevant), the image is scaled up but cropped with the wrong dimensions.

Captured on a non-retina display:

gemeinderat-total

Captured on a retina display:

gemeinderat-total-retina

Possibly related to #38.

Specifying a small canvas size doesn't work

When I set the h/w to, for example, 320x365 (for capturing the canvas of an iPhone-targeted site in portrait mode), the actual screengrab ends up being 8xx by 8xx anyway. I've worked around this locally by adding an -iphone option that overrides options.[height, width, initHeight, initWidth], but in an overtly hacky way.

Specify a delay to allow flash to load

Iโ€™m not sure if this is even possible, but it would be nice to specify a delay on the command line to allow flash movies to load addition resources.

Grabbing an element by CSS class when it has more than one class

Hello,

I was not able to specifically grab an element when it had more than on css class applied and I wanted to select by the 2nd class.

Code:

...

I want to grab by ".egmMatchInfoLineup"

Running this query:
/usr/local/bin/webkit2png '/Users/jan/Desktop/greb/single-saf.html' -F --selector=.egmSnippetContent -o saf

throws an error. Unfortunately I don't know how to debug, so sorry for trying to get some help this way. If there is another / preferred way, please let me know.

best,
Jan

PDF generation

The discussion in #27 has a convincing argument about why PDF generation would be a good idea, and the pull request includes some code on how to achieve it, but the command line arguments need some work (we don't want to generate PDFs by default). Tracking that in the pull request will be difficult so I'm opening this issue.

README.md should mention OS X dependency

If I am not mistaken, webkit2png depends on Python package Quartz, a python wrapper around OS X' CoreGraphics. If so, Linux (and Windows) users would only waste their time trying to get it to run. Please add a note. Thank you!

Offset pixels

Hi,

I very glad this script exist! It's a simple way of making my project idea come to live.
But know I have a question/request. Is it possible to create an offset.

I'll explain it better, I would like to only take one pixel of a website, but I don't want it to be the one in the corner of the X,Y axes. Would it be possible to create an offset.

I have no knowledge of python what so ever?

I tried to contact the author himself, but apparently there's no mail adres of him on the net.

kind regards,

Cookie support

Taking a full size screenshot of a web app that requires login could be supported via a cookies file. The user would log in via their browser, then tell webkit2png to use the cookies file as a source, or perhaps specify which browser's cookies to use as a source for ease of use to the end user.

Safari stores its cookies in a plist database in:
~/Library/Cookies/Cookies.plist

Google Chrome stores its cookies in a sqlite database in:
~/Library/Application Support/Google/Chrome/Default/Cookies

Firefox stores its cookies in a sqlite database in a non-guessable path:
~/Library/Application Support/Firefox/Profiles/????????.default/cookies.sqlite

send custom device-pixel-ratio?

It would be nice to have an option to send a device-pixel-ratio other than 1 (to target retina-scale graphics on compatible sites).

Need to be able to process html files

Hi,
As I understand it, webkit2png needs an URL to process, it can't process a html file. I would need it to be able to process html files. That would open lots of uses.

Thanks

Bump version every now and then

Just noticed I had an old version on my machine without the option to disable JS and some other things. webkit2png --version said I was using v0.5 though. Please consider updating the version number every now and then to make it easier to see if an update has been released.

Thank you for this wonderful tool!

Flash makes python crash

Hi,

$ webkit2png http://i.liketightpants.net/and/talking-of-content

fails with

Fetching http://i.liketightpants.net/and/talking-of-content ...
2011-03-16 13:29:43.597 Python[36677:d0f] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary.
2011-03-16 13:29:43.599 Python[36677:d0f] CFPropertyListCreateFromXMLData(): Old-style plist parser: missing semicolon in dictionary.
Segmentation fault

Full crash report

Several other pages on the same site give the same CFPropertyList error but they do obtain a result.

Thanks,

Eric

Erroneous Divider Showing Up

I'm having an issue running webkit2png on a JS-heavy app I'm working on. For some reason, the thumbnails are being printing with this divider running right through them:

image

It seems that by setting a large enough height (-H 4000), the problem goes away. I'm assuming the divider issue occurs when the page is long to need to combine multiple screenshots.

Any ideas on why this happening and/or how to fix this?

Java Applets

Java applets do not currently render in webkit2png. It would be very useful to add this functionality.

Output to standard input

Is it possible to create this so that the files/filenames(s) are returned via standard input?

For example:

webkit2png http://apple.com -F | lp -

prints:

Fetching http://apple.com ...
 ... done

:(

url parameters giving errors

I am trying to get a screenshot of a dynamic page and as such I need to pass url variables to the command line call but it throws errors. Can someone help me with how to format this. I am not very good with command line at this point so I am a little lost.

This is the call I make:
webkit2png -F http://localhost:8888/report.php?0%5BStart+Date%5D=2013-05-01&0%5BEnd+Date%5D=2013-05-31

And this is the error I get:
[1] 11891 -bash: 0%5BEnd+Date%5D=2013-05-31: command not found

I don't know if it is is possible, but could I somehow pass a $_SESSION var through the command line? This would solve the issue as well.

Thanks!

Very very long pages can cause crashes

While testing a fix for issue #20 I noticed that incredibly long pages can cause huge amounts of memory to be used, eventually causing the window server to crash.

Ideally we'd avoid this by putting some kind of hard limit to how much webkit2png tries to capture.

Documentation fixes

Some things that should be better:

  • The new --js and --transparent options could do with some more documentation, either in the README or on the website.
  • The homebrew package should be mentioned.
  • Installing on old versions of Mac should be moved somewhere else.
  • The two commands to download and chmod should be written down for those that don't have homebrew.
  • The difference between zoom and scale needs to be explained.

Output to clipboard

Rather a feature request than an issue: What do you think of clipboard output instead of a file?

Screengrabbing local file with query string doesn't work

I tried to run the script to take a screenshot of a local html file with a query string:

$ webkit2png /tmp/file.html?test=test
Fetching file://localhost/tmp/file.html%3Ftest=test ...
 ... something went wrong: The requested URL was not found on this server.

Error importing WebKit

Hi, when I run the script I have the following message:

MacMa:~ mdgart$ python ~/Desktop/webkit2png www.google.com
Traceback (most recent call last):
File "/Users/mdgart/Desktop/webkit2png", line 34, in
import WebKit
File "build/bdist.macosx-10.3-fat/egg/WebKit/init.py", line 11, in

AttributeError: 'module' object has no attribute 'initFrameworkWrapper'

I'm not able to find the file "build/bdist.macosx-10.3-fat/egg/WebKit/init.py" and i have no idea where is the module WebKit that you import on line 34.
BTW: PyObjC is installed and i'm on Leopard 10.5.8

Note in README that DYLD_LIBRARY_PATH should be empty if using MAMP

When calling webkit2png from a PHP script from within a MAMP server (see http://www.mamp.info/) the script fails during the PyObjC imports due to a missing symbol in libjpeg.

Possible solutions:

  • Include note in README about how DYLD_LIBRARY_PATH should be empty (verified to work)
  • Before importing PyObjC packages in the script, "import os; del os.environ['DYLD_LIBRARY_PATH']" (untested)

Further info:

http://www.princexml.com/bb/viewtopic.php?p=3496&sid=c351ebad7ec5eff6a979b94dfeaabe7e#3496

A response from the MAMP developers:
Quote:

yes, MAMP changes the environment variable $DYLD_LIBRARY_PATH. Check the file:
/Applications/MAMP/Library/bin/envvars
and try out if commenting out the two uncommented lines will work for you.

Trying to get local files, even with file:// not working

Hey there, thanks so much for this library! It's making a dream project of mine a reasonable goal.

I'm trying super hard to figure this out but am completely stuck, if I put

file:///users/eric/src/project/output/index.html into the browser it gets the page no problem

webkit2png file:///users/eric/src/ericcarmichael/output/index.html however outputs:

Fetching file:///users/eric/src/ericcarmichael/output/index.html ...
2014-04-15 20:26:26.553 Python[20173:1107] <type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'representationUsingType_properties_'
2014-04-15 20:26:26.554 Python[20173:1107] (
    0   CoreFoundation                      0x00007fff8534c25c __exceptionPreprocess + 172
    1   libobjc.A.dylib                     0x00007fff82c9fe75 objc_exception_throw + 43
    2   CoreFoundation                      0x00007fff8534be09 -[NSException raise] + 9
    3   _objc.so                            0x000000010d156626 PyObjCFFI_MakeClosure + 2197
    4   libffi.dylib                        0x00007fff889dfa1f ffi_closure_unix64_inner + 509
    5   libffi.dylib                        0x00007fff889df11e ffi_closure_unix64 + 70
    6   CoreFoundation                      0x00007fff852b3564 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
    7   CoreFoundation                      0x00007fff852b309f __CFRunLoopDoTimer + 1151
    8   CoreFoundation                      0x00007fff853245aa __CFRunLoopDoTimers + 298
    9   CoreFoundation                      0x00007fff8526e8e5 __CFRunLoopRun + 1525
    10  CoreFoundation                      0x00007fff8526e0b5 CFRunLoopRunSpecific + 309
    11  HIToolbox                           0x00007fff84489a0d RunCurrentEventLoopInMode + 226
    12  HIToolbox                           0x00007fff844897b7 ReceiveNextEventCommon + 479
    13  HIToolbox                           0x00007fff844895bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
    14  AppKit                              0x00007fff8db673de _DPSNextEvent + 1434
    15  AppKit                              0x00007fff8db66a2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
    16  AppKit                              0x00007fff8db5ab2c -[NSApplication run] + 553
    17  libffi.dylib                        0x00007fff889def9c ffi_call_unix64 + 76
    18  ???                                 0x00007f8dca446390 0x0 + 140246960595856
)

It's probably something small I'm missing. In any case, sorry to bother and thanks for any help!

Need to be packaged (setup.py; PyPI)

If a package is made out of it using setup.py (see http://guide.python-distribute.org/) - it can be uploaded to PyPI for users to install with a simple "pip install webkit2png" command. On Windows, this even automatically creates .exe wrappers.

I once wrote a tool to automate much of layout creation: http://pypi.python.org/pypi/modern-package-template -- once this tool is installed:

$ paster create -t modern_package webkit2png && cd webkit2png
$ cp ~/code/webkit2png/webkit2png src/webkit2png/__init__.py
$ python bootstrap.py && bin/buildout
$ bin/webkit2png

$ python setup.py sdist register upload

Eg: http://github.com/srid/codebackup

Let me know if you need help with this -- I can fork and work on it.

NSImageCacheException - Can't cache image

Hi,

I think I have a nice challenge for you: I got the "NSImageCacheException - Can't cache image" whenever I include scale and use the next url http://www.wpdesigner.com/2007/03/17/wp-theme-lesson-16-comments-template/ If I remove scale, problem dissapears, but I really need clipped version of the image...

python wk2png --width=1024 --clipwidth=1024 --clipheight=768 --filename=test --scale=1.0 http://www.wpdesigner.com/2007/03/17/wp-theme-lesson-16-comments-template/

Note 1: I think this might be important, because I'm just starting with webkit2png and there's probably other urls that might trigger that error too

Note 2: I don't know about python nor cocoa. I did my best trying to figure what couldbe the problem. "scale" seems to be, but I can't go further without your knowledge. I hope you can help me.

David Moena

Configurable timeout

I'm on a slow hotel wifi network, and the 60 second timeout is too slow for some sites. It would be nice if this was an option.

make it work on Linux / Windows

Since webkit is available on other platforms as well (via pyqt, pygtkwebkit), it would be nice to make this module portable across those platforms.

Proxy support

A user requested a --proxy command line parameter to override system proxy settings

Rendering ripples if `width` is insufficient

In v0.5 of webkit2png, rendering http://fictivekin.com/ was fine. As of 0.6 (and current HEAD), the resulting default image is rippled, and the small text is poorly-rendered.

HEAD on left, 0.5 on right (you'll need to zoom/show this full sized to see it, probably):
ripples

However, if I specify -W 1024 when capturing, I get the unrippled version.
If I specify -W 800 (same as the default), I get the rippled image.

I took a quick dive into the options calculations, and it doesn't seem to be a floating point error, or similar. I don't grok the internals, though.

Remove support for multiple URLs

When capturing multiple URLs from one instance of webkit2png, the following error occurs:

Python[10560:1107] *** WebKit discarded an uncaught exception in the webView:didFinishLoadForFrame: delegate: <NSUnknownKeyException> [<DOMAbstractView 0x7ff0650d3b30> valueForUndefinedKey:]: this class is not key value coding-compliant for the key webkit2png.

Have tracked it down to the new Webkit2PngScriptBridge. With the code for that commented out, it works fine.

possible errors in error handling

Hello together,

our company is using webkit2png by Paul Hammond in a web service since some time and we are very grateful for this piece of script doing such a great job, especially with the new delay option.
On testing this new version we found that error handling in webView_didFailLoadWithError_forFrame_ might produce more errors than it should, preventing webpages from being loaded which normally should load.
This particularly is true with pages containing reloadable content like flash or javascript, as the following German examples show:
http://www.rae-bachmann-hansen.de
http://www.vincon-kaelte.de
http://www.kolb-architekten.de
These homepages are loaded and captured only if getURL in webView_didFailLoadWithError_forFrame_ is commented out otherwise the application will be terminated.

Maybe our findings will be useful in improving his beautiful little application.

Kind regards,
Werner Paskuy

Use data uri instead of url

Currently this doesn't work:

webkit2png "data:text/html,<body><h2>Hello World</h2></body>"

Is there another way to do this? Or possibly have this added as a feature?

NSURLErrorDomain error -999

On some pages webkit2png doesn't work because it throws a "NSURLErrorDomain error -999" error.

I speculate it has something to do with asynchronous assets that are cancelled.

Should this exception simply be ignored?

Rails & webkit2png

Hi, Im using rails and trying to execute webkit2png from a controller, but it creates an empty image, this doesnt happend when I do it from the console, I try everything.
Anyone with the same issue?

Support for IDN domain names

It'd be nice if you could run webkit2png http://www.โ˜ƒ.net/ and have it work. Unfortunately NSURL doesn't support IDNs easily.

tag releases, please (for Homebrew)

Homebrew really needs tagged releases or other measures for stable, versioned downloads. Otherwise the formula breaks for every new release and setting the version is a mess.

Would be great if you could tag the current version right now.

Related discussion.
Homebrew/legacy-homebrew#18744

Seems to fail on 301 redirects

Fetching http://www.bankofthewest.com/mobile-banking/mobile-banking.html ...
2013-03-25 14:09:33.673 Python[4048:1307] <type 'exceptions.AttributeError'>: cannot access attribute 'representationUsingType_properties_' of NIL 'NSBitmapImageRep' object
2013-03-25 14:09:33.675 Python[4048:1307](0 CoreFoundation 0x00007fff87a75b06 __exceptionPreprocess + 198
1 libobjc.A.dylib 0x00007fff8be0c3f0 objc_exception_throw + 43
2 CoreFoundation 0x00007fff87b09f49 -[NSException raise] + 9
3 _objc.so 0x00000001077e8366 PyObjCFFI_MakeClosure + 4418
4 libffi.dylib 0x00007fff8ad578a6 ffi_closure_unix64_inner + 508
5 libffi.dylib 0x00007fff8ad56f66 ffi_closure_unix64 + 70
6 CoreFoundation 0x00007fff87a32804 CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION + 20
7 CoreFoundation 0x00007fff87a3231d __CFRunLoopDoTimer + 557
8 CoreFoundation 0x00007fff87a17ad9 __CFRunLoopRun + 1529
9 CoreFoundation 0x00007fff87a170e2 CFRunLoopRunSpecific + 290
10 HIToolbox 0x00007fff8b855eb4 RunCurrentEventLoopInMode + 209
11 HIToolbox 0x00007fff8b855c52 ReceiveNextEventCommon + 356
12 HIToolbox 0x00007fff8b855ae3 BlockUntilNextEventMatchingListInMode + 62
13 AppKit 0x00007fff8fc4b563 _DPSNextEvent + 685
14 AppKit 0x00007fff8fc4ae22 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128
15 AppKit 0x00007fff8fc421d3 -[NSApplication run] + 517
16 libffi.dylib 0x00007fff8ad56de4 ffi_call_unix64 + 76
17 ??? 0x00007f94c53422c0 0x0 + 140276940415680)

Web fonts from Hoefler & Frere-Jones / typography.com don't work

I'll look into the details and differences later, but the web fonts as provided by Hoefler & Frere-Jones don't seem to work with webkit2png. Google web fonts, self-hosted from Font Squirrel and TypeKit hosted fonts all seem to work, so there must be some difference in how H&FJ are serving them.

example-typography com

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.