Skip to content
smallPict

Officiële Ruby SDK

Officiële gem voor Ruby on Rails, ActiveStorage en Sinatra.

Eenvoudige en elegante integratie met Ruby on Rails, ActiveStorage en Sinatra.


Installatie

Shell
gem install smallpict# of in uw Gemfilegem 'smallpict', '~> 1.2'

Compleet toepassingsvoorbeeld

Ruby
require 'smallpict'
client = SmallPict::Client.new(  api_key: ENV['SMALLPICT_API_KEY'],  secret_key: ENV['SMALLPICT_SECRET_KEY'])
# 1. Lokaal bestand optimaliserenresult = client.optimize(  file: File.read('hero.png'),  filename: 'hero.png',  format: 'avif',  quality: 80)
puts "CDN-URL: #{result.url}"puts "Besparing: #{result.savings_percentage}%"
# 2. Quotum opvragenquota = client.get_quotaputs "Resterend tegoed: #{quota.remaining} / #{quota.total}"