Ruby & Rails SDK

Official smallpict gem for Ruby on Rails, Sinatra, and Sidekiq worker environments.

Ruby SDK (smallpict)

The official SmallPict Ruby gem provides idiomatic integration for Ruby 3.0+ and Ruby on Rails.


📦 Installation

gem install smallpict
# or in your Gemfile
gem 'smallpict'

🚀 Quickstart Example

require 'smallpict'

client = SmallPict::Client.new(
  api_key: ENV['SMALLPICT_API_KEY'],
  secret_key: ENV['SMALLPICT_SECRET_KEY']
)

# 1. Optimize an image
file_bytes = File.binread('hero.jpg')
result = client.optimize(
  source: file_bytes,
  format: 'avif',
  quality: 80
)

puts "Optimized URL: #{result.url}"
puts "Savings: #{result.savings_percentage}%"