No browser runtime to maintain
Keep Rails applications and background jobs free of separate browser processes and browser-specific deployment dependencies.
HTML to JPEG with Ruby
No browser management required
Render HTML and CSS from Ruby without installing Chrome, running Ferrum or Selenium, or building a separate image-storage pipeline.
Ruby workflow
Adjust the HTML and CSS here, then use the Ruby example below instead of recreating the browser-rendering workflow locally.
Managed rendering
Keep the application code focused on the request and response while HCTI manages Chromium, render isolation, retries, and hosted output.
Keep Rails applications and background jobs free of separate browser processes and browser-specific deployment dependencies.
Use managed browser versions, isolated render jobs, built-in timing controls, and consistent viewport behavior across deployments.
Receive the hosted .jpeg result without building a separate pipeline for temporary files, uploads, storage, and delivery.
HTML to image API
POST the HTML, CSS, and format from Ruby. HCTI handles the browser lifecycle and returns the generated .jpeg URL.
Send complete markup and styles, including browser-supported fonts, images, SVG, and JavaScript.
Set format to jpeg and use the hosted .jpeg URL returned by the API.
Set viewport dimensions and device scale, or crop the result to a CSS selector.
Choose light or dark mode, timezone, and screen or print media.
How it works
Submit the content with format set to jpeg and any viewport or browser settings.
The API loads the markup, styles, fonts, and assets in a managed browser environment.
Embed the hosted result, download the file, or save it in your own storage and application records.
Output formats
Keep the same HTML and CSS. Choose lossless detail, compact compatibility, modern web delivery, or a paginated document.
Looking to capture a webpage as JPEG? Explore URL to JPEG in RubyCrisp text, sharp UI details, and transparent backgrounds for designed graphics.
Explore PNGStrong visual quality, transparency, and modern compression for web delivery.
Explore WebPPaginated documents with page sizing, margins, backgrounds, and print styles.
Explore PDFExample code
Copy a complete Ruby request. Authentication, HTML, CSS, viewport settings, and response handling are shown together.
require "json"
require "net/http"
require "uri"
request = {
html: <<~'HCTI_HTML',
<div class="card">
<h1>Hello, world!</h1>
<p>Generated from HTML and CSS.</p>
</div>
HCTI_HTML
css: <<~'HCTI_CSS',
.card {
width: 480px;
padding: 40px;
background: #f0fdf4;
color: #052e16;
font-family: sans-serif;
}
HCTI_CSS
format: "jpeg",
}
uri = URI("https://hcti.io/v1/image")
http_request = Net::HTTP::Post.new(uri)
http_request.basic_auth(ENV.fetch("HCTI_API_ID"), ENV.fetch("HCTI_API_KEY"))
http_request["Content-Type"] = "application/json"
http_request.body = JSON.generate(request)
response = Net::HTTP.start(
uri.hostname,
uri.port,
use_ssl: true,
open_timeout: 10,
read_timeout: 30
) { |http| http.request(http_request) }
unless response.is_a?(Net::HTTPSuccess)
raise format("HCTI request failed (%s): %s", response.code, response.body)
end
result = JSON.parse(response.body)
puts result.fetch("url")
Ready to render?
Send HTML and CSS to the API and receive a hosted .jpeg image URL without running browser infrastructure.