Search code examples
phpjavascripthtmlimage-manipulation

HTML to Image file using Painty


I am using Painty. http://www.rabuser.info/painty.php So far so good. But my question is now how would I make it create the image file instead of outputting it to the screen. In fact I want it to create it without the user even going to the page maybe through AJAX.

In the end this is how it will flow. They will go to there profile. From there it run some ajax and create an image from some HTML i specified and display the image on there profile. They would also be able to link to this image and show it off hence the reason I want it to be a file.


Solution

  • After imagepng($im); you can add this line:

    imagejpeg($im, 'yoo.jpg', 75); //creates jpeg file at 75 percent quality
    

    if it still doesn;t work, then:

    After $html=@$_GET['html']; add this line:

     $html='<h1>Painty Heading</h1><hr/><p>Welcome<br /><b>Yo...</b></p><p align = right><img src="http://static.php.net/www.php.net/images/php.gif" align="right" /></p>';
    

    and after 'font_path' => $__SERVER["DOCUMENT_ROOT"], add this line:

    'font_path' => "./",
    

    and i also recommend these fonts:

    'font' => "VeraMono.ttf",
    'font_bold' => "VeraMoBd.ttf",
    

    find those files in C:\Windows\fonts