Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

royo1987's avatar

HTML to Image

Hi, I'm using Laravel 5.7.

Today I'm here asking for any library that I can use to convert HTML to an image.

I tried PhantomMagick https://github.com/anam-hossain/phantommagick/tree/1.0.2 (I also installed PhantomJS, cuz it's required for PhantomMagick to work) I'm getting an error that I don't know how to fix and I can't find a solution online.

Error: Binary does not exist, in C:\xampp\htdocs\pogochecklist\vendor\anam\phantommagick\src\Runner.php and this is the code that is giving me the Error.


        if (! $this->verifyBinary($this->binary)) {
 
            if (! $this->verifyBinary($this->getAlternateBinary())) {
                throw new Exception('Binary does not exist');
            }
 
            $this->binary = $this->getAlternateBinary();
        }

So, any library that I can use to convert HTML to an image?

0 likes
5 replies
willvincent's avatar
Level 54

Can be done client side with javascript, just have to render html in a canvas element, then do a canvas .toDataURL() call to generate png, jpg, etc.

1 like
royo1987's avatar

Thanks @willvincent very easy to use, I got an Image of my HTML, I still need to figure out some things, but I think they wont be much trouble.

Please or to participate in this conversation.