public function capture(Screenshot $screenshot)
 {
     $request = $this->client->getMessageFactory()->createCaptureRequest($screenshot->url, 'GET');
     $request->setCaptureFile($screenshot->storagePath);
     $request->setViewportSize($screenshot->width, $screenshot->getViewportHeight());
     $request->setTimeout(1000);
     $request->setDelay(1);
     // Delay Rendering for 1 sec (Animations etc.)
     /*
      * If height is set by user, crop the image
      */
     if (isset($screenshot->height)) {
         $request->setCaptureDimensions($screenshot->width, $screenshot->height, 0, 0);
     }
     $response = $this->client->getMessageFactory()->createResponse();
     $this->client->send($request, $response);
 }
Beispiel #2
0
 /**
  * Create Screenshot and Redirect to Try-Route.
  *
  * @return Illuminate\Http\RedirectResponse
  */
 public function createTestScreenshot()
 {
     $proof = trim(strtolower(Input::get('proof')));
     if ($proof != 'laravel') {
         return redirect()->route('home.landingpage');
     }
     $url = Input::get('url');
     // Validate Input
     $validator = new ScreenshotValidator();
     $validator->validate(Input::all());
     // Check if Host is available
     $checkHost = new CheckHostService();
     $checkHost->ping($url);
     // Actually Capture the Screenshot
     $screenshot = new Screenshot();
     $filename = $screenshot->generateFilename();
     $screenshot->setPath('images/try/');
     $screenshot->setStoragePath($filename);
     $screenshot->setHeight(Input::get('height'));
     $screenshot->setWidth(Input::get('width', 1024));
     $screenshot->capture($url);
     return redirect()->route('try')->with('asset', $screenshot->assetPath);
 }
 /**
  * @expectedException Illuminate\Contracts\Filesystem\FileNotFoundException
  */
 public function testScreenshotDoesnExist()
 {
     $screenshot = new Screenshot();
     $screenshot->setStoragePath('filename.jpg');
     File::get($screenshot->storagePath);
 }