I'm looking for a way to convert html tags to a image on the fly...
That means, that I want to be able to make a image_tag with a path to a method which returns the image created form html.
I was looking for a solution on that, but couldn't come up with a proper way to solve that...
Any Ideas?
Maechi
IMGkit can do the job (details on github)
Create JPGs using plain old HTML+CSS
kit = IMGKit.new('http://google.com')
kit.to_jpg
kit.to_jpeg
kit.to_png
kit.to_tif
kit.to_tiff
or in your controller
@kit = IMGKit.new(render_as_string)
format.jpg do
send_data(@kit.to_jpg, :type => "image/jpeg", :disposition => 'inline')
end
I'm going to take a wild guess here and guess that you want to convert HTML to an image, so take a "snapshot" of a web page or something. I'm not sure exactly how to do this in one step, but one way to do it is to use PDFKit to convert to PDF and then use RMagick to convert to whatever image format you want.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With