Giter Site home page Giter Site logo

screenshot-as-a-service's Introduction

Screenshot as a Service

A simple screenshot web service powered by Express and PhantomJS. Forked from screenshot-app.

Setup

First install phantomjs, then clone this repo and install the deps:

$ npm install

Run the app:

$ node app
Express server listening on port 3000

Usage

For a quick test with the command line, type:

$ curl http://localhost:3000/?url=www.google.com > google.png

Here is the complete usage documentation, also accessible on /usage.html:

# Take a screenshot
GET /?url=www.google.com
# Return a 1024x600 PNG screenshot of the www.google.com homepage

# Custom viewport size
GET /?url=www.google.com&width=800&height=600
# Return a 800x600 PNG screenshot of the www.google.com homepage

# Disable JavaScript
GET /?url=www.google.com&javascriptEnabled=false
# Return a screenshot with no JavaScript executed

# Custom User Agent
GET /?url=www.google.com&userAgent=Mozilla%2F5.0+%28iPhone%3B+CPU+iPhone+OS+5_0+like+Mac+OS+X%29+AppleWebKit%2F534.46+%28KHTML%2C+like+Gecko%29+Version%2F5.1+Mobile%2F9A334+Safari%2F7534.48.3
# Return a screenshot using an iPhone browser
# (User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 5_0 like Mac OS X) AppleWebKit/534.46 (KHTML, like Gecko) Version/5.1 Mobile/9A334 Safari/7534.48.3)

# Clipping Rectangle
GET /?url=www.google.com&clipRect=%7B"top"%3A14%2C"left"%3A3%2C"width"%3A400%2C"height"%3A300%7D
# Return a screenshot clipped at {"top":14,"left":3,"width":400,"height":300}

# HTTP Authentication
GET /?url=www.mysite.com&userName=johndoe&password=S3cr3t
# Return a screenshot of a website requiring basic http authentication

# Asynchronous call
GET /?url=www.google.com&callback=http://www.myservice.com/screenshot/google
# Return an empty response immediately (HTTP 200 OK),
# then send a POST request to the callback URL when the screenshot is ready
# with the PNG image in the body.

# Screenshot delay
GET /?url=www.google.com&delay=1000
# Return a 1024x600 PNG screenshot of the www.google.com homepage
# 1 second after it's loaded

# Use an HTML form to ask for a screenshot
GET /form.html

Screenshots are cached for one minute, so that frequent requests for the same screenshot don't slow the service down. You can adjust or disable caching in the project configuration (see below).

Configuration

Create a config/development.yaml or a config/production.yaml to override any of the settings found in the config/default.yaml:

rasterizer:
  command: phantomjs   # phantomjs executable
  port: 3001           # internal service port. No need to allow inbound or outbound access to this port
  path: '/tmp/'        # where the screenshot files are stored
  viewport: '1024x600' # browser window size. Height grows according to the content
cache:
  lifetime: 60000      # one minute, set to 0 for no cache
server:
  port: 3000           # main service port

For instance, if you want to setup a proxy for phantomjs, create a config/development.yaml as follows:

rasterizer:
  command: 'phantomjs --proxy=myproxy:1234'

Asynchronous Usage Example

Here is an example application that takes asynchronous screenshots of a list of websites at regular intervals and saves them to disk:

var http = require('http');
var url  = require('url');
var fs   = require('fs');

// create a server to receive callbacks from the screenshot service
// and save the body to a PNG file
http.createServer(function(req, res) {
  var name = url.parse(req.url).pathname.slice(1);
  req.on('end', function () {
    res.writeHead(200);
    res.end();
  });
  req.pipe(fs.createWriteStream(__dirname + '/' + name + '.png'));
}).listen(8124);
console.log("Server running on port 8124");

var sites = {
  'google': 'http://www.google.com',
  'yahoo':  'http://www.yahoo.com'
};
var screenshotServiceUrl = 'http://my.screenshot.app:3000/'; // must be running screenshot-app

// call the screenshot service using the current server as a callback
var poller = function() {
  for (name in sites) {
    var options = url.parse(screenshotServiceUrl + sites[name] + '?callback=http://localhost:8124/' + name);
    http.get(options, function(res) {});
  };
}
setInterval(poller, 60000);

Every minute, this script will refresh the two screenshots google.png and yahoo.png.

TODO

  • Allow to configure phantomjs options through YAML config
  • Implement a simple queuing system forcing the use of asynchronous screenshots when the number of browser processes reaches the limit

License

(The MIT License)

Copyright (c) 2012 François Zaninotto, TJ Holowaychuk <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

screenshot-as-a-service's People

Contributors

danschumann avatar denisjacquemin avatar fzaninotto avatar jamesmanning avatar lahdekorpi avatar nkouevda avatar smeinecke avatar thanpolas avatar thulio avatar tj 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

screenshot-as-a-service's Issues

rasterizer hangs forever

  1. $ cat package.json

{
"name": "screenshot-as-a-service",
"description": "Website screenshot service powered by node.js and phantomjs",
"version": "1.1.0",
"repository": "https://github.com/fzaninotto/screenshot-as-a-service",
"engines": {
"node": ">=0.8.4"
},
"dependencies": {
"express": "3.x",
"config": "0.4.15",
"request": "2.9.153"
}
}

  1. /node_modules/phantomjs/bin/phantomjs --version
    1.9.8

  2. ps 25756

    PID TTY STAT TIME COMMAND
    25756 ? Rl 13941:31 /home/thumbnailer/screenshot-as-a-service/node_modules/phantomjs/lib/phantom/bin/phantomjs scripts/rasterizer.js /home/thumbnailer/cache/ 3001 1024x600

  3. strace -p 25756
    These snippets cycled

    gettimeofday({1452852831, 5280}, NULL) = 0
    gettimeofday({1452852831, 5482}, NULL) = 0
    gettimeofday({1452852831, 7324}, NULL) = 0
    gettimeofday({1452852831, 7524}, NULL) = 0
    mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f20ef601000
    mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f20ef5ff000
    munmap(0x7f2086b99000, 4096) = 0
    mmap(NULL, 16384, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f20ea039000
    munmap(0x7f20ef5ff000, 8192) = 0
    mmap(NULL, 32768, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f2086ba9000
    munmap(0x7f20ea039000, 16384) = 0
    mmap(NULL, 65536, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS|MAP_NORESERVE, -1, 0) = 0x7f2086b99000
    munmap(0x7f2086ba9000, 32768) = 0
    munmap(0x7f2086b9a000, 61440) = 0
    munmap(0x7f20ef601000, 8192) = 0
    munmap(0x7f2086ba9000, 32768) = 0
    munmap(0x7f2086b9a000, 61440) = 0
    munmap(0x7f20ef601000, 8192) = 0
    gettimeofday({1452852831, 52296}, NULL) = 0
    gettimeofday({1452852831, 54358}, NULL) = 0
    gettimeofday({1452852831, 54600}, NULL) = 0
    gettimeofday({1452852831, 56494}, NULL) = 0
    gettimeofday({1452852831, 56705}, NULL) = 0
    gettimeofday({1452852831, 58602}, NULL) = 0
    gettimeofday({1452852831, 58810}, NULL) = 0
    gettimeofday({1452852831, 60763}, NULL) = 0
    gettimeofday({1452852831, 60983}, NULL) = 0
    gettimeofday({1452852831, 62877}, NULL) = 0
    gettimeofday({1452852831, 63193}, NULL) = 0
    gettimeofday({1452852831, 65047}, NULL) = 0

Generate screenshot after javascript event?

Hi there,

I'd like the screenshots my app creates to wait until a javascript event is fired (or a timeout is reached). Is there any way to do that currently with screenshot-as-a-service?

If not, how would you recommend I add this? I'm happy to do the work, would love some direction.

Thanks!
Tim

Service fails when width is specified

Running under Mac OS X 10.6.8

I installed as instructed below. The first example works as expected.

When I try

$ curl http://localhost:3000/?url=www.google.com&width=800&height=600 > google.png

It appears that maybe the image data is being dumped to the console. In any case, the output file is created, but contains zero bytes.

The console output (abbreviated):

dev:screenshot-as-a-service glen$ curl http://localhost:3000/?url=www.google.com&width=800&height=600 > google.png
[1] 5679
[2] 5680
dev:screenshot-as-a-service glen$ #PNG

IHDR######d#IT  pHYs

                    ## IDATx###w#Uս######g###J#
                                               v#####g4M###$57Ɩ####_######xը##1#`##JS)#A#t########g
                                                                                                   }#3s`###<x0####s####Y##Yf#########
                                                                                                                                     r݄6################8x###f###"""""""Y #######r9##R#T###
                                      ##
                                        c#############e
#"""""""mH#N@#N 

<snip>

#
#
#
##�h4           #Y##IEND#B`#

Here the process 'hangs', that is, no change is observed for a few minutes. Aborting the process with Ctrl-C adds the following and returns to the prompt.

[1]-  Done                    curl http://localhost:3000/?url=www.google.com
[2]+  Done                    width=800
dev:screenshot-as-a-service glen$ 

Any ideas or troubleshooting suggestions would be most welcomed!

Heroku compatibility

Hey there,

It's been great using screenshot.etf1.fr, but it's now offline. I tried running this app on heroku and ran into perhaps four issues:

  1. Exceeding the memory limitation (perhaps the process can be configured to use less):
    heroku[web.1]: Process running mem=531M(103.8%)
    heroku[web.1]: Error R14 (Memory quota exceeded)
  2. It looks like the app uses the file system and AFAIK that's not allowed with Heroku.
  3. The heroku log shows repeated failing attempts to use execvp:
    app[web.1]: phantomjs error: execvp(): No such file or directory
  4. It's not legal to use extra ports, whcih phantomjs appears to be using:
    app[web.1]: Phantomjs internal server listening on port 3001

Are these surmountable problems do you think?

Cheers,
Merlyn

Screenshot Service continues to kill and restart phantom in many request scenario

We recently ran into a situation where we're sending thousands of "jobs" that hit this screenshot service one after another (in our tests we were actually hitting the service with two different workers, so a maximum of 2 simultaneous requests would be coming in, but they send a new request as soon as the previous one finishes).

Pretty reliably, phantom will start to consume too much memory and crash (we think we can easily resolve this by making more resources available to this process, but ultimately won't fix this issue we're seeing). When phantom crashes, the screenshot service restarts it on the next request, however, if a request comes in before phantom is "ready" to accept new requests, the screenshot service will receive a ECONNREFUSED error from phantom, which triggers the restart process all over again. This ends up causing phantom to be killed and restarted every time a request comes in after the initial crash. In our case, this will basically clear out our job queue, failing every request because phantom isn't given enough time to start up before the screenshot service kills and restarts it.

I have been testing a small fix that will at least give phantom some time to restart before the kill/start process is initiated, but wanted to solicit some input from the community on how to best deal with this.

Ideally, it seems that the request that kicks off the restart of phantom should wait until phantom is ready before returning the response, and any requests that come in during this time should also block until phantom is ready. I didn't see an obvious way to tell if phantom is "ready", other than receiving a successful rasterize response from it. Is there some sort of callback we can use, or event we can listen for to determine if phantom is started and ready for requests? Should the restart request loop on an interval until it can get a successful response from phantom? (begs the question, what if phantom never starts, is this request stuck in a loop?)

My "fix" that I'm testing currently takes a slightly different approach, sort of in tune with how the screenshot service acts currently. The restart of phantom is kicked off, but the restarting request will return an error response (as it does now). However, it sets a variable to prevent any subsequent requests from also killing and restarting phantom (they'll just return an error response as well if this variable is set) but once phantom is up and returns a valid response (or the pingcheck comes back successfully), this variable is wiped in case phantom needs to be restarted in the future. So when hitting the screenshot service with thousands of back to back requests, this may cause a handful of them to fail when phantom is down, but will recover once phantom is back up rather than returning an error response for every subsequent request.

Note that I don't see the issue mentioned in #32 as the phantom process is definitely killed and restarted. If I watch output from ps I see the process id on the phantom process change every time ps is updated (and there is only ever one (or none) process hanging around).

Charset issue?

Check a screenshot for www.doctoroz.com. Note that in Chrome, you will see downward-pointing triangle characters in the main navigation menus. But in the screenshots, there are the good old "unknown character" box placeholders.

Is the service not fully UTF-8 aware?

500 Error: ENOENT, stat '/tmp/

Hi :

I've been trying to get screenshot-as-a-service to work but I keep on getting the folowing error:

500 Error: ENOENT, stat '/tmp/screenshot_fb9e1b0a971d302426bf475bd3e192d9.png' (on The Browser)

and :

Request for http://GET /?url=www.yahoo.com - Rasterizing it
Sending image in response
Error: ENOENT, stat '/tmp/screenshot_fb9e1b0a971d302426bf475bd3e192d9.png'

(On the Console.)

node --version v0.6.15 (install and default through nvm)
phantomjs --version 1.6.2 (working)

I've tried to change the path to other directories with 777 permissions, but to no avail
Any ideas what am I doing wrong ? I am running out of ideas.

Thanks in advance
Keno

Stopping Phantomjs internal server

Everytime there is an error, the server stops, and you manually have to restart the server again.

Anyone else who´ve had this problem?

More information:
Request for http://www.YYYYYYYYY.se - Rasterizing it
Sending image in response
Error: ENOENT, stat '/tmp/screenshot_668da469560fdc4ca0f48fffc6bfd417.png'

[uncaughtException] { [Error: ENOENT, no such file or directory '/tmp/screenshot_668da469560fdc4ca0f48fffc6bfd417.png']
errno: 34,
code: 'ENOENT',
path: '/tmp/screenshot_668da469560fdc4ca0f48fffc6bfd417.png',
syscall: 'unlink' }
Stopping Phantomjs internal server

phantomjs failed

[email protected] ~/js/screenshot-as-a-service
├─┬ [email protected] 
│ ├── [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ └── [email protected] 
├─┬ [email protected] 
│ ├─┬ [email protected] 
│ │ └── [email protected] 
│ ├── [email protected] 
│ ├── [email protected] 
│ └── [email protected] 
└── [email protected] 

$ node --version
v0.6.14

i've downgraded node.js with nvm

on Linux 3.2.0-27-generic (ubuntu)

$ node app.js 
Phantomjs internal server listening on port 3001
Express server listening on port 3000

openig http://localhost:3000/?url=www.google.com ...

screenshot - rasterizing http://www.google.com
Error
    at Request._callback (~/js/screenshot-as-a-service/routes/index.js:55:23)
    at Request.callback (~/js/screenshot-as-a-service/node_modules/request/main.js:119:22)
    at Request.<anonymous> (~/js/screenshot-as-a-service/node_modules/request/main.js:212:58)
    at Request.emit (events.js:67:17)
    at ClientRequest.<anonymous> (~/js/screenshot-as-a-service/node_modules/request/main.js:209:10)
    at ClientRequest.emit (events.js:67:17)
    at Socket.onend (http.js:1188:13)
    at TCP.onread (net.js:389:26)
Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
phantomjs failed; restarting
Phantomjs internal server listening on port 3001

node app crashed

sorry, i am newbie to node.js
but when i use this app to get this url(http://www.oneteaspoon.com.au/Sale.aspx?pl1202) 's screenshot, the app got crashed.
i think this is a bug,
here is crash info:

Request for http://www.oneteaspoon.com.au/Sale.aspx?pl1202 - Rasterizing it
Sending image in response
Error: ENOENT, stat '/home/app/projects/screenshot-as-a-service/tmp/screenshot_583b4acf24397e68ffcd02be46850765.png'
[uncaughtException] { [Error: ENOENT, no such file or directory '/home/app/projects/screenshot-as-a-service/tmp/screenshot_583b4acf24397e68ffcd02be46850765.png']
  errno: 34,
  code: 'ENOENT',
  path: '/home/app/projects/screenshot-as-a-service/tmp/screenshot_583b4acf24397e68ffcd02be46850765.png',
  syscall: 'unlink' }
Stopping Phantomjs internal server

but when i try to take screenshot from google, then it's work. i use node.js 0.8.8

pdf support ?

can the service generate searchable/selectable pdf or is it image only

Height param seems to be ignored

I tried to use the height param to control the size of the window/screenshot but it seems to be being ignored e.g.

http://localhost:3000/?url=http://m.guardian.co.uk/&width=320&height=100 produces an image of 320x7200
I would expect an image off 320x100?
As a workaround I am using clipRect
Is this a bug or am I misunderstanding the behaviour of the height parameter?

Error: ENOENT, no such file or directory '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png'

It looks like we have a problem with file cache:

Sending image in response
Error: ENOENT, stat '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png'
{ [Error: ENOENT, no such file or directory '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png']
  errno: 34,
  code: 'ENOENT',
  path: '/tmp/screenshot_85be4ad4e95551dd3481a21275ffbe8c.png',
  syscall: 'unlink' }
Request for http://https://www.google.ru/url?sa=t,https://sites.google.com/?hl=ru - Rasterizing it

Resizing screenshot

Not sure if already implemented but how do I take a screenshot and then resize it? With today's responsive designs in order to get screenshot properly I've to take a screenshot at 1280x1024 and then resize it to 200x160. Cliprect doesn't help here obviously :)

Does not work with Node 0.8

npm WARN engine [email protected]: wanted: {"node":">= 0.4.1 < 0.7.0"} (current: {"n
ode":"0.8.2","npm":"1.1.36"})

Should I downgrade to 0.7.0?

after 'node app' I've got:

p:\canvas-9\screenshot-as-a-service>node app

child_process.js:777
var r = this._handle.spawn(options);
_________________^
TypeError: Bad argument
at ChildProcess.spawn (child_process.js:777:24)
at exports.spawn (child_process.js:614:9)
at RasterizerService.startService (p:\canvas-9\screenshot-as-a-service\lib\rasterizerService.js:32:21)
at Object. (p:\canvas-9\screenshot-as-a-service\app.js:11:19)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.runMain (module.js:492:10)
at process.startup.processNextTick.process._tickCallback (node.js:244:9)

The NPM list:

p:\canvas-9\screenshot-as-a-service>npm list
[email protected] p:\canvas-9\screenshot-as-a-service
├─┬ [email protected]
│ ├── [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ └── [email protected]
├─┬ [email protected]
│ ├─┬ [email protected]
│ │ └── [email protected]
│ ├── [email protected]
│ ├── [email protected]
│ └── [email protected]
└── [email protected]

I tried to run application on Win7 (64) / nodejs 0.8.2

run curl http://localhost:3000/?url=www.google.com > google.png get error

Error
at Request._callback (/home/app/screenshot-as-a-service/routes/index.js:82:25)
at Request.self.callback (/home/app/screenshot-as-a-service/node_modules/request/main.js:119:22)
at Request. (/home/app/screenshot-as-a-service/node_modules/request/main.js:212:58)
at emitOne (events.js:77:13)
at Request.emit (events.js:169:7)
at ClientRequest.self.clientErrorHandler (/home/screenshot-as-a-service/node_modules/request/main.js:209:10)
at emitOne (events.js:77:13)
at ClientRequest.emit (events.js:169:7)
at Socket.socketErrorListener (_http_client.js:267:9)
at emitOne (events.js:77:13)

Better support for HTTPS websites

Pages Rendering With Wrong Webfont

I'm having some weird issues with wrong (from previous sites) webfonts are shown.

Test case:

  1. Boot up the service
  2. Load http://x.local that uses a .woff: "Montserrat-Regular"
  3. Screenshot works as it should be with the correct font
  4. Load http://y.local that uses a .woff: "Sansation-Regular"
  5. Screenshot shows the site using "Montserrat-Regular" instead of the correct one
  6. killall phantomjs
  7. Load http://y.local again
  8. Screenshot works as it should be with the correct font
  9. Load http://x.local again
  10. Screenshot shows the site using "Sansation-Regular" instead of the correct one

TL;DR: Once a webfont is loaded, all pages show up with that one.

Not rendering SVG

Heyo, I'm having some trouble with pages that use SVG / icon fonts (specifically font-awesome). I'm just getting a placeholder. Is this normal? and can I fix it somehow with a delay / flag?

localhost

localhost-1

DOM Manipulation

Is there a place where I can make DOM manipulation before render? Working with DOM in 'scripts/rasterizer.js' in 'server.listen' doesnt give any results.

Stopping Phantomjs internal server

I git cloned this repo

Then used npm install

Then installed phantomjs using brew install phantomjs

Then started the server using 'node app'

Server started ok

Made request using: curl http://localhost:3000/?url=www.google.com > google.png

The request fails and the server keeps repeating the phrases:

Phantomjs internal server listening on port 3001
Express server listening on port 3000
Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001

Delay to get the screen shot

Hi
When i try http://localhost:3000/?url=www.yahoo.com at first time am getting an error message

500 Error: ENOENT, no such file or directory '/tmp/screenshot_cfda6ec6bad14c5c5eeaf006ab17671c.png'

and after a few seconds when i refresh i am getting the image, i feel a little time delay there

Is there any way to solve this?anyone having this issue

how can i solve this

Note am using latest version of node also

Thanks in advance

Sanjay.M

Phantomjs Processes Won't Stop

My test case:

  • Run screenshot-as-a-service
  • Do 5 queries every 2 seconds
  • Wait for screenshot-as-a-service to crash

And the result is oprhaned phantomjs processes consuming memory:
Kuvankaappaus 2013-4-8 kello 16 21 34

Crash:

Sending image in response
[uncaughtException] { [Error: ENOENT, no such file or directory '/tmp/screenshot_a0759a220b50b287388af42c0149a3fe.png']
  errno: 34,
  code: 'ENOENT',
  path: '/tmp/screenshot_a0759a220b50b287388af42c0149a3fe.png',
  syscall: 'unlink' }
Stopping Phantomjs internal server

fs.js:760
  return binding.unlink(pathModule._makeLong(path));
                 ^
Error: ENOENT, no such file or directory '/tmp/screenshot_b49924b800f523f831a2c84f4ebcd53b.png'
    at Object.fs.unlinkSync (fs.js:760:18)
    at FileCleanerService.removeFile (/opt/screenshot-service/screenshot-as-a-service/lib/fileCleanerService.js:41:6)
    at FileCleanerService.removeAllFiles (/opt/screenshot-service/screenshot-as-a-service/lib/fileCleanerService.js:46:10)
    at process.<anonymous> (/opt/screenshot-service/screenshot-as-a-service/lib/fileCleanerService.js:21:10)
    at process.EventEmitter.emit (events.js:117:20)
    at process.exit (node.js:707:17)
    at process.app.configure.app.use.express.errorHandler.dumpExceptions (/opt/screenshot-service/screenshot-as-a-service/app.js:11:11)

Support for PhantomJS 2.0.0

Currently the service does not function on PhantomJS 2.0.0. One reason is that scripts/rasterizer.js uses phantom.args which has been deprecated and removed in PhantomJS 2.0.0. There may be other issues as well, as a quick switch to the "system.args" still caused 500 errors.

feature request: put a device frame around a screenshot

This is probably beyond the scope of this particular library, but I just figured I'd offer a suggestion. How about giving the option to place the screenshot image inside of a frame for a tablet, smartphone, laptop, or desktop LCD panel? That's oftentimes the next step for me when I'm preparing screenshot to include in product documentation or marketing materials.

Here's an example: http://www.appdemostore.com/frameapp

[uncaughtException] { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }

Hi,

I just downloaded the zip file and tun the following commands:

npm install
node app.js

it gives me that error:

[uncaughtException] { [Error: spawn ENOENT] code: 'ENOENT', errno: 'ENOENT', syscall: 'spawn' }

i also tried it with sudo command but the error didn't change.

finally i tried to give chmod 777 to all files in the current folder but the result didn't change.

what can id in this situaiton?

Adding support for Flash

Hi,
i am sorry for that i put on wrong place my comment.

As i say i am working on a project where its need to have a url to screenshot feature and test your screenshot-as-a-service but my problem is the flash websites. My question is do you know how to fix it or is that functionality will be included soon?

Cheers

nodev6.10.1版本进行安装出现下列问题

express deprecated app.configure: Check app.get('env') in an if statement app.js:24:5
Phantomjs internal server listening on port 3001
express deprecated app.configure: Check app.get('env') in an if statement app.js:30:5
Express server listening on 127.0.0.1:3000
phantomjs output: TypeError: undefined is not an object (evaluating 'phantom.args[0]')

phantomjs output: phantomjs://code/rasterizer.js:9 in global code

Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
phantomjs output: TypeError: undefined is not an object (evaluating 'phantom.args[0]')

phantomjs output: phantomjs://code/rasterizer.js:9 in global code

Phantomjs process is sleeping. Restarting.
Stopping Phantomjs internal server
Phantomjs internal server listening on port 3001
phantomjs output: TypeError: undefined is not an object (evaluating 'phantom.args[0]')

phantomjs output: phantomjs://code/rasterizer.js:9 in global code

The service is not working

Hi,
I am sorry to post it here, because i cannot find a forum here.

Today, I have downloaded it, unzip it, and follow the document, however i cannot get it work due to an exception.

node screenshot-as-a-service-master\app.js

module.js:340
throw err;
^
Error: Cannot find module 'config'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (D:\Working Folder\Projects\NodeJS\screenshot-as-a-service-master\app.js:4:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)

I am using Windows 7 32 bit, and NodeJS v0.10.28, and PhantomJS 1.9.7

Any help will be very appreciated!

My Best,
Hung Tran

Keep getting no such file directory

Hi

I'm guessing I haven't installed something properly but I'm getting the following error:

500 Error: ENOENT, no such file or directory '/tmp/screenshot_31b9768c340c66086764f9acd7968f94.png'

I would be very grateful if you have any ideas what I might have done wrong.

Thanks very much

Chris

Deprecated functions.

express deprecated app.configure: Check app.get('env') in an if statement app.js:24:5
express deprecated app.configure: Check app.get('env') in an if statement app.js:30:5

Just thought you might want to know this.

Canonot find module 'config'

I get that error when I try to run the app

C:...\screenshot>node app

module.js:340
throw err;
^
Error: Cannot find module 'config'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object. (C:\Program Files\nodejs\node_modules\screenshot\app.j
s:4:14)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)

Service fails when width is specified

Running under Mac OS X 10.6.8

I installed as instructed below. The first example works as expected.

When I try

$ curl http://localhost:3000/?url=www.google.com&width=800&height=600 > google.png

It appears that maybe the image data is being dumped to the console. In any case, the output file is created, but contains zero bytes.

The console output (abbreviated):

dev:screenshot-as-a-service glen$ curl http://localhost:3000/?url=www.google.com&width=800&height=600 > google.png
[1] 5679
[2] 5680
dev:screenshot-as-a-service glen$ #PNG

IHDR######d#IT  pHYs

                    ## IDATx###w#Uս######g###J#
                                               v#####g4M###$57Ɩ####_######xը##1#`##JS)#A#t########g
                                                                                                   }#3s`###<x0####s####Y##Yf#########
                                                                                                                                     r݄6################8x###f###"""""""Y #######r9##R#T###
                                      ##
                                        c#############e
#"""""""mH#N@#N 

<snip>

#
#
#
##�h4           #Y##IEND#B`#

Here the process 'hangs', that is, no change is observed for a few minutes. Aborting the process with Ctrl-C adds the following and returns to the prompt.

[1]-  Done                    curl http://localhost:3000/?url=www.google.com
[2]+  Done                    width=800
dev:screenshot-as-a-service glen$ 

Any ideas or troubleshooting suggestions would be most welcomed!

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.