All Projects → igorkasyanchuk → omg_image

igorkasyanchuk / omg_image

Licence: MIT license
Generate PNG previews for HTML snippets (html/css/js). Any complexity.

Programming Languages

ruby
36898 projects - #4 most used programming language
HTML
75241 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to omg image

Chromda
λ 🖼️ Chromda is an AWS Lambda function for capturing screenshots of websites.
Stars: ✭ 481 (+1617.86%)
Mutual labels:  screenshot, chrome-headless
screenie-server
A Node server with a pool of Puppeteer (Chrome headless) instances for scalable screenshot generation.
Stars: ✭ 19 (-32.14%)
Mutual labels:  screenshot, chrome-headless
Webshot Factory
Web Screenshots at scale based on headless chrome
Stars: ✭ 288 (+928.57%)
Mutual labels:  screenshot, chrome-headless
Gowitness
🔍 gowitness - a golang, web screenshot utility using Chrome Headless
Stars: ✭ 996 (+3457.14%)
Mutual labels:  screenshot, chrome-headless
Chart To Aws
Microservice to generate screenshot from a webpage and upload it to a AWS S3 Bucket.
Stars: ✭ 43 (+53.57%)
Mutual labels:  screenshot, chrome-headless
Lancia
网页转PDF渲染服务。提供收据、发票、报告或任何网页内容转PDF的微服务
Stars: ✭ 108 (+285.71%)
Mutual labels:  screenshot, chrome-headless
Go Stare
A fast & light web screenshot without headless browser but Chrome DevTools Protocol!
Stars: ✭ 87 (+210.71%)
Mutual labels:  screenshot, chrome-headless
Api
API that uncovers the technologies used on websites and generates thumbnail from screenshot of website
Stars: ✭ 189 (+575%)
Mutual labels:  screenshot, chrome-headless
snipped
🖥️ 🖼️ Create fancy screenshots of your code without leaving the editor.
Stars: ✭ 98 (+250%)
Mutual labels:  screenshot
svg-screencast
SVG screencast - animated SVG files from screenshots using CSS animations
Stars: ✭ 28 (+0%)
Mutual labels:  screenshot
mpv crop script
A Lua script to take cropped screenshots in mpv, sans external dependencies
Stars: ✭ 77 (+175%)
Mutual labels:  screenshot
goverview
goverview - Get an overview of the list of URLs
Stars: ✭ 93 (+232.14%)
Mutual labels:  screenshot
fb-post-screenshot
Firefox Web Extension to save Facebook posts as images
Stars: ✭ 18 (-35.71%)
Mutual labels:  screenshot
Backdoor
A backdoor that runs on Linux and Windows
Stars: ✭ 36 (+28.57%)
Mutual labels:  screenshot
gsu
A general screenshot and upload utility for images, video, and gifs.
Stars: ✭ 18 (-35.71%)
Mutual labels:  screenshot
GitYourFeedback
Let users submit feedback, with screenshots, directly from your iOS app to Github Issues
Stars: ✭ 60 (+114.29%)
Mutual labels:  screenshot
autoscreen
Automated screen capture utility
Stars: ✭ 76 (+171.43%)
Mutual labels:  screenshot
acmpv
使用 mpv 播放带弹幕的 Acfun & Bilibili 视频
Stars: ✭ 27 (-3.57%)
Mutual labels:  screenshot
JamTools
JamTools是一个跨平台的小工具集,包含了截屏、录屏、文字识别、各种格式转换、鼠标键盘动作录制播放、文件传输、聊天机器人等功能
Stars: ✭ 73 (+160.71%)
Mutual labels:  screenshot
browser-shots
A WordPress plugin for taking screenshots of websites using the block editor.
Stars: ✭ 17 (-39.29%)
Mutual labels:  screenshot

omg_image

RailsJazz https://www.patreon.com/igorkasyanchuk

Let's start with sample of what this gem can do (below are the images of generated previews):

Demo: https://www.youtube.com/watch?v=Lso-B_fayhw

Sample

If you need to generate complex images, previews, charts or basically represent any HTML snippet - this gem could help.

It's using a Chrome(headless) to convert any HTML to PNG.

If you want to try, you just need a 5 min to see how it works. Gem is comming with an examples which you can modify and use in your real app.

Usage

  • add this gem to Gemfile - gem "omg_image"
  • make sure you have chrome installed (google-chrome --version)
  • execute rails g omg in app
  • execute rake db:migrate
  • edit sample template app/omg/simple.html.erb
  • open any view, for example you have app/views/home/index.html.erb and put:
  <%= image_tag OmgImage::Processor.new('entity', key: 'xxx', title: "OMG,<br/>this looks interesting!", tags: ['This', 'is', 'a', 'sample'], description: "Change me please", size: '600,300').cached_or_new %>
  <br/>
  <%= image_tag OmgImage::Processor.new('entity', title: "OMG,<br/>this looks interesting!", description: "Small version", size: '400,200').cached_or_new(regenerate: true) %>
  <br/>
  <%= image_tag OmgImage::Processor.new('square', title: "Real-time generation", size: '200,200').cached_or_new %>
  • refresh page and see images
  • edit/create new previews and use them in any place of your app.

Also, for example you can do it on generate images directly in the models:

class Post < ApplicationRecord
  has_one_attached :preview
  # just an example
  def Post.create_new_preview
    processor = ::OmgImage::Processor.new('entity', title: "OMG,<br/>this is created from model", description: "Small version", size: '400,200')
    processor.with_screenshot do |screenshot|
      post = Post.new
      post.preview.attach(io: File.open(screenshot.path), filename: "image.png", content_type: "image/png")
      post.save!
    end
  end
end

To create a new template - basically create a new file in app/omg/<name>.html.erb. Put any HTML/CSS into it. And use as described above.

Requirements

  • Rails App 5+ and Active Storage
  • Google chrome (headless)

Installation

Add this line to your application's Gemfile:

gem 'omg_image'

And then execute:

$ bundle

Features

  • you can generate images with any complexity (you just need to know html/css)
  • store cached versions of preview by key and you can obtain them by OmgImage::Image.find_by(key: key)
  • generate images in background jobs or console applications
  • caching for previews by key
  • ability to refresh preview by key

Options

  • .cached_or_new(regenerate: true) pass this option with true value if you want to regenerate image

Google Chrome Installation

  • sudo apt install gdebi-core
  • wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
  • sudo gdebi google-chrome-stable_current_amd64.deb
  • verify chrome is installed google-chrome --version

More about Chrome

Issues

  • if you process too many requests and because of timeouts dead processes may appear. To kill them parents_of_dead_kids=$(ps -ef | grep [d]efunct | awk '{print $3}' | sort | uniq | egrep -v '^1$'); echo "$parents_of_dead_kids" | xargs kill

TODO

  • ability to configure app (path to chrome for example)
  • more samples (with layout)
  • wiki pages with documentation and samples
  • ability to preview templates directly by URL
  • tests/specs
  • options to delay rendering (could be useful if use JS libraries or external assets)
  • support remote URL's to render (so it would possible to capture screenshots for example)

Contributing

You are welcome to contribute.

Inspirations

I've noticed that in a past that articles on dev.to site without images when you sending a link in skype or sharing in FB have have nice preview, so I've implemented similar solution :)

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].