rattler Posted November 16, 2011 Share Posted November 16, 2011 Hello All, I have been given the task of creating a dynamic tempting system which needs to take text input and render an image in a restaurant menu format. I have had a look into the GD functions in PHP but they appear unable to handle HTML code (imagettftext), as that would enable me to pre-format the text then simply convert this to one big image. As these functions do not support HTML the only other option is to loop through for each line of text and create another image inside one big container then render this final image. So my questions are: Is there any way to render HTML as an image using GD library or another 3rd party add on? Is there a better way anyone can think to solve this? Thanks in advance Quote Link to comment https://forums.phpfreaks.com/topic/251257-php-gd-and-html/ Share on other sites More sharing options...
QuickOldCar Posted November 16, 2011 Share Posted November 16, 2011 You render the final html any way you like and using w/e methods, then snapshot that as an image. should be able to render the menus as html, take a snapshot of them, and include the image to the clients site for display. Quote Link to comment https://forums.phpfreaks.com/topic/251257-php-gd-and-html/#findComment-1288695 Share on other sites More sharing options...
rattler Posted November 16, 2011 Author Share Posted November 16, 2011 So there is no way to create an image from HTML using GD? Quote Link to comment https://forums.phpfreaks.com/topic/251257-php-gd-and-html/#findComment-1288702 Share on other sites More sharing options...
QuickOldCar Posted November 16, 2011 Share Posted November 16, 2011 Gd and imagemagic could easily take an image of html. The hardest part is rendering it the same as a browser does. I use both firefox and Internet Explorer to take snapshots. For Firefox I use this free plugin http://pearlcrescent.com/products/pagesaver/ For IE I use a simple COM method http://php.net/manual/en/function.imagegrabwindow.php is quite a few ways and scripts made for doing this, I've found these 2 above work the best and most useful. What you are looking for is website snapshot, or thumbnail snapshot, something similar. Then resize/crop to what you need. some other similar ones webthumb http://www.boutell.com/webthumb/ iesnap - trial http://www.tonec.com/products/iesnap/index.html cutycapt http://cutycapt.sourceforge.net/ html snapshot - trial http://html-snapshot.en.softonic.com/ thumbs from websites and uses iecapt - no linux, windows only http://www.zubrag.com/scripts/website-thumbnail-generator.php is many others, and also online sites that can snap html images for you. here is the basics for doing it in linux Create a headless X server with something like Xvfb and virtual buffer. Open some sort of browser on that in-memory X window. for windows use com or printsceen fullscreen browser with no toolbars Screenshot the contents of that browser. Render that screenshot content out to some image format, I stick with png images. Save images with unique names using timestamp, or use md5 and keep track of the image names, I use a discovery method finding multiple common website urls, but thats just for what I do. If image doesn't then exist I snap one. Resize and crop image if needed Quote Link to comment https://forums.phpfreaks.com/topic/251257-php-gd-and-html/#findComment-1288712 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.