Setup CloudConvert to take webpage screenshots
This commit is contained in:
parent
0d393bd172
commit
45c71bbb47
7 changed files with 177 additions and 38 deletions
|
@ -15,15 +15,14 @@ use GuzzleHttp\Exception\ClientException;
|
|||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Support\Str;
|
||||
use Ramsey\Uuid\Uuid;
|
||||
use Spatie\Browsershot\Browsershot;
|
||||
use Spatie\Browsershot\Exceptions\CouldNotTakeBrowsershot;
|
||||
|
||||
class BookmarkService extends Service
|
||||
{
|
||||
/**
|
||||
* Create a new Bookmark.
|
||||
*
|
||||
* @param array $request Data from request()->all()
|
||||
* @param array $request Data from request()->all()
|
||||
* @param string|null $client
|
||||
* @return Bookmark
|
||||
*/
|
||||
public function create(array $request, ?string $client = null): Bookmark
|
||||
|
@ -75,31 +74,6 @@ class BookmarkService extends Service
|
|||
return $bookmark;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a URL, use `browsershot` to save an image of the page.
|
||||
*
|
||||
* @param string $url
|
||||
* @return string The uuid for the screenshot
|
||||
*
|
||||
* @throws CouldNotTakeBrowsershot
|
||||
*
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function saveScreenshot(string $url): string
|
||||
{
|
||||
$browsershot = new Browsershot();
|
||||
|
||||
$uuid = Uuid::uuid4();
|
||||
|
||||
$browsershot->url($url)
|
||||
->setIncludePath('$PATH:/usr/local/bin')
|
||||
->noSandbox()
|
||||
->windowSize(960, 640)
|
||||
->save(public_path() . '/assets/img/bookmarks/' . $uuid . '.png');
|
||||
|
||||
return $uuid->toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a URL, attempt to save it to the Internet Archive.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue