# Convert html to image

**URL:** <https://www.ruby-forum.com/t/convert-html-to-image/151482>\
**Category:** Ruby\
**Created:** [October 22, 2008, 2:42am UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482 "2008-10-22T02:42:01Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cjokomay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@cjokomay](https://www.ruby-forum.com/u/cjokomay)\
**Post date:** [October 22, 2008, 2:42am UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482/1 "2008-10-22T02:42:01Z")

</div>

I would like to take an html file, or even just an html string, and  
convert it to an image (e.g. jpg or png). Unfortunately I have no idea  
where to even begin. I imagine that it would involve the use of  
rmagick, in fact I believe its possible to convert html to pdf and  
then pdf to image, so I will start researching that angle.

Any help would be greatly appreciated, even a just a push in the right  
direction would be great!

Thank you.

---

<div class="post-metadata">

**Author:** ![cjokomay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@cjokomay](https://www.ruby-forum.com/u/cjokomay)\
**Post date:** [October 23, 2008, 3:05pm UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482/2 "2008-10-23T15:05:21Z")

</div>

On Wed, 22 Oct 2008 02:39:20 +0200, cjokomay [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I would like to take an html file, or even just an html string, and  
> convert it to an image (e.g. jpg or png).

Shall the image show (possibly syntax highlighted) HTML source or  
rendered  
HTML and if the latter rendered using which engine? Please indicate the  
operating systems(s) the software is to work on because the solution is  
likely to depend on it.

Josef ‘Jupp’ Schugt

---

<div class="post-metadata">

**Author:** ![cjokomay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@cjokomay](https://www.ruby-forum.com/u/cjokomay)\
**Post date:** [October 24, 2008, 3:13pm UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482/3 "2008-10-24T15:13:57Z")

</div>

I would like to ask this too - is there a somewhat easy way to  
“simulate” a user viewing a remote html page and have ruby capture the  
resulting image, as if he were to look at it via browser, but _without_  
any user interaction? (i.e. a “silent” ruby script to produce such  
images)

---

<div class="post-metadata">

**Author:** ![cjokomay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@cjokomay](https://www.ruby-forum.com/u/cjokomay)\
**Post date:** [October 24, 2008, 1:15pm UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482/4 "2008-10-24T13:15:31Z")

</div>

On 23 oct, 15:02, Josef ‘Jupp’ Schugt [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> –  
> Blog:[http://penpen.goodaddress.eu/](http://penpen.goodaddress.eu/)  
> PGP key (id 6CC6574F):[http://wwwkeys.de.pgp.net/](http://wwwkeys.de.pgp.net/)  
> Jabber -[http://www.jabber.org/-](http://www.jabber.org/-) contact information on request

Hi,

I would like to do smae thing. So, if I understand your answer, we  
should first choose one html renderer: gecko, webkit, etc…

Is it correct ? Thanks !!

Regards,  
José Luis

---

<div class="post-metadata">

**Author:** ![cjokomay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@cjokomay](https://www.ruby-forum.com/u/cjokomay)\
**Post date:** [October 24, 2008, 7:05pm UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482/5 "2008-10-24T19:05:42Z")

</div>

On Oct 21, 2008, at 6:39 PM, cjokomay wrote:

> would like to take an html file, or even just an html string, and  
> convert it to an image (e.g. jpg or png). Unfortunately I have no idea  
> where to even begin. I imagine that it would involve the use of  
> rmagick, in fact I believe its possible to convert html to pdf and  
> then pdf to image, so I will start researching that angle.
> 
> Any help would be greatly appreciated, even a just a push in the right  
> direction would be great!
> 
> Thank you.

look at the image magick label functions, it’s possible that alone  
will give you want you want: which is, i assume, to dump a text string  
into an image.

a @ [http://codeforpeople.com/](http://codeforpeople.com/)

---

<div class="post-metadata">

**Author:** ![cjokomay](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/96bed5/32.png) [@cjokomay](https://www.ruby-forum.com/u/cjokomay)\
**Post date:** [October 27, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/convert-html-to-image/151482/6 "2008-10-27T14:21:23Z")

</div>

If you’re talking about web page thumbnails (not sure about the OP but  
some of the follow-ups are), then you may be able to use this:

[http://cutycapt.sourceforge.net/](http://cutycapt.sourceforge.net/)

– Mark.
