Project

html_to

0.0
No release in over a year
Simple gem for transforms html page through chromium headless to image.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 7.0.6

Runtime

 Project Readme

codecov build Gem Version

HtmlTo ๐Ÿ”ฅ

HtmlTo is a gem for Rails that allows you to generate images from an HTML file.๐Ÿ’ก

๐Ÿ“‹ Table of Contents

  • Installation๐Ÿš€
  • Usage ๐Ÿ“–
  • Advanced usage ๐Ÿงฐ

Installation

You need to have Chrome or Chromium installed ๐Ÿ› ๏ธ And active-storage is required

Ubuntu:

sudo apt install -y chromium-browser

Debian:

apt-get install chromium chromium-l10n

add gem to your gemfile

gem 'html_to'

copy example serializer with

 rails generate html_to:install

optional

for set path to chromium executable

#confg/initializers/html_to.rb
HtmlTo::Configuration.config do |config|
  config.chromium_path = './path-to-executable'
end

to optimize attached images add gem 'image_processing'

Basic usage

Add to your model ๐Ÿ“–

  include HtmlTo
  html_to HtmlToSerializer

Now after save your model new image will generated and attached to meta_image in your model

Advanced usage

available options for customizations ๐Ÿงฐ

  html_to HtmlTo::DummySerializer, image_name: :my_image, template: :image
option descriotions default
image_name name of attachment meta_image
template HTML template circle
synchronous Run image generation job not in background false
skip_auto_update skip auto update after save false
width width of image 1200
height height of image 630

template customization

there are two templates available circle and image for copy to your project:

rails generate html_to:copy_template

you can add your own template to app/views/html_to/*