For some security reasons, I would like to generate an image based on Google Calendar embed iframe, to be able to show it on a website who don't allow iframes.
Is there any php library to create an image from html?
The script have to be executable on a linux server.
Generating images with PHP The API takes your HTML/CSS and runs it inside a real instance of Google Chrome to convert your html into an image. Use PHP to send the API your HTML/CSS. You'll get back json with the URL to your generated image.
Here's the easiest way to create an image of a webpage: Browsershot::url('https://example.com')->save($pathToImage); Browsershot will make an education guess where Google Chrome is located.
php $img = imagecreate(500, 300); $bgcolor = imagecolorallocate($img, 150, 200, 180); $fontcolor = imagecolorallocate($img, 120, 60, 200); imagestring($img, 12, 150, 120, "Demo Text1", $fontcolor); imagestring($img, 3, 150, 100, "Demo Text2", $fontcolor); imagestring($img, 9, 150, 80, "Demo Text3", $fontcolor); ...
use Spatie\Browsershot\Browsershot; Browsershot::url('https://example.com')->save($pathToImage); Browsershot::url('https://example.com') ->setScreenshotType('jpeg', 100) ->save($pathToImage); Browsershot::url('https://example.com') ->windowSize(640, 480) ->save($pathToImage);
The library wkhtmltoimage works perfectly.
I have created a page to embed the google calendar (the url can't be reach directly).
I generate a picture from this page and I link this image on my profile on the website.
Thanks heaps for the comments.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With