Re: Howto Save/Convert HTML into JPEG/PNG with Perl
by jettero (Monsignor) on Apr 17, 2007 at 15:01 UTC
|
Personally, I'm not aware of any way to do this short of loading up the html in a browser and issuing a screencap of the browser window. The main reason is that it takes 30 megs of compiled bloat for firefox to render an html file and the conversion is browser dependent.
| [reply] |
|
|
| [reply] |
A reply falls below the community's threshold of quality. You may see it by logging in.
|
Re: Howto Save/Convert HTML into JPEG/PNG with Perl
by isync (Hermit) on Apr 17, 2007 at 20:56 UTC
|
So 1 more who'd like to enter the multi-million dollar business of thumbnail generation! ;-)
In fact I found 3 solutions.
1. You can use html2ps -> then convert the .ps with imagemagick to a .png (works, but all thumbs have a white background - as html2ps is intended for printing)
2. The medium-weight approach of using a browser's render engine and get the output (I used the kwebdesktop library on linux and got mediocre results so far, render errors and no flash, and I think it wastes a LOT of memory! and I can't control the user-agent string easily)
3. The heavy-weight approach of using an external browser and take a capture of the browser's window. Which I didn't try so far as I dislike the idea of the overall design.
Remark 1: To my knowledge there is no all-in-one html-render-and-output-as-image module on cpan.
Remark 2: Which module on Corion?
| [reply] |
|
|
It would be helpful if some would let me know...how i can convert a htmlcontent into png....ASAP
| [reply] |
|
|
| [reply] [d/l] |
|
|
| [reply] |
Re: Howto Save/Convert HTML into JPEG/PNG with Perl
by dragonchild (Archbishop) on Apr 17, 2007 at 15:15 UTC
|
If you're in OSX, you can use Automator to take screenshots. If you're in Linux, I'm pretty sure that there are similar scripting utilities. Perl isn't always the best solution.
My criteria for good software:
- Does it work?
- Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
| [reply] |
Re: Howto Save/Convert HTML into JPEG/PNG with Perl
by moklevat (Priest) on Apr 17, 2007 at 15:07 UTC
|
It sounds like you would like a module that will read the HTML file, render it, and then write out a png or jpeg image of the rendered page. Perhaps someone else knows of such a beast, but my cursory look through CPAN did not turn this up.Since the structure of the figure is relatively simple, a bunch of tables each containing rectangle-on-a-line with varying offsets, you may be better off parsing the HTML file to extract the sequence information and offset data (the first "td width=" in each table) and rendering rectangle-on-a-lines in PNG using GD::Simple. This would give you more control over the appearance of the image
Update:Ooh, Look at that! Corion found a module that would work after all. | [reply] |
Re: Howto Save/Convert HTML into JPEG/PNG with Perl
by FreeBeerReekingMonk (Deacon) on Aug 25, 2016 at 12:40 UTC
|
I think you need an additional tool to interface with the Windows Win32 GDI routines:
I would just install AutoIT3, and use their screencapture capabilities
And here is a guy that made a image resize, which you use after saving it to a temporal file.
I could not find additional libs in perl that had screen capture abilities.
In Linux, there are build in things, like xwd or ImageMagick to automate screenshots. | [reply] |