screen
screen copied to clipboard
Blurry screenshots
If I try to take a screenshot of the following url, it comes out "blurry".
https://twitter.com/KeanuReevesoff1/status/1047128450547556353
Below is the code that I've written.
function takeScreenshotOfUrl(string $url, int $width = 400, int $height = 500): ?string { $saveLocation = $SERVER['DOCUMENT_ROOT'] . '/screenshots/'; $fileName = date("y_m_d__G_i_s"); $counter = 0; do { $tempFileName = $fileName . ($counter > 0 ? "" . $counter : "") . ".png"; ++$counter; } while (file_exists($tempFileName)); $fileName = $tempFileName; unset($counter, $tempFileName);
if ($height > 500)
$height = 500;
$screenCapture = new Capture($url);
$screenCapture->setWidth($width);
$screenCapture->setHeight($height);
$screenCapture->setImageType('png');
$screenCapture->setDelay(5000);
$screenCapture->save($saveLocation . fileName);
if (file_exists($saveLocation . $fileName))
return $fileName;
return null;
}