Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate image from html with php

Tags:

html

php

image

gd

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.

like image 650
Julien Ducro Avatar asked Jul 15 '11 05:07

Julien Ducro


People also ask

How to create image from HTML in php?

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.

How to convert webpage to image in php?

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.

How to create image in php example?

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); ...

How can convert HTML image to laravel?

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);


1 Answers

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.

like image 161
Julien Ducro Avatar answered Oct 22 '22 00:10

Julien Ducro