Offizielles Ruby SDK
Offizielles Gem für Ruby on Rails, ActiveStorage und Sinatra.
Integration in Ruby on Rails, ActiveStorage und Sinatra-Anwendungen.
Installation
Shell
gem install smallpict# oder in Ihrem Gemfilegem 'smallpict', '~> 1.2'Vollständiges Codebeispiel
Ruby
require 'smallpict'
client = SmallPict::Client.new( api_key: ENV['SMALLPICT_API_KEY'], secret_key: ENV['SMALLPICT_SECRET_KEY'])
# 1. Lokales Bild optimierenresult = client.optimize( file: File.read('hero.png'), filename: 'hero.png', format: 'avif', quality: 80)
puts "CDN URL: #{result.url}"puts "Ersparnis: #{result.savings_percentage}%"
# 2. Kontingent abfragenquota = client.get_quotaputs "Verfügbares Kontingent: #{quota.remaining} / #{quota.total}"