Official Gem for Generating ImageBoss URLs. https://imageboss.me/
Table of Contents
- Required: Ruby
>= 1.9.0(see gemspec). - Tested in CI: Latest 2.x and 3.x (Ruby 2.7 and 3.4). Ruby 1.9 is no longer available on current CI runners (see CI workflow).
Add this line to your application's Gemfile:
bundle add imageboss-rb
Or install it yourself as:
gem install imageboss-rb
client = ImageBoss::Client.new(source: 'mywebsite')
image_url = client.path('/images/img01.jpg')
.operation(:cover, width: 100, height: 100)
#=> https://img.imageboss.me/mywebsite/cover/100x100/images/img01.jpgclient = ImageBoss::Client.new(source: 'mywebsite')
image_url = client.path('/images/img01.jpg')
.operation(:height, height: 100)
#=> https://img.imageboss.me/mywebsite/height/100/images/img01.jpgclient = ImageBoss::Client.new(source: 'mywebsite')
image_url = client.path('/images/img01.jpg')
.operation(:width, width: 100, options: { grayscale: true })
#=> https://img.imageboss.me/mywebsite/width/100/grayscale:true/images/img01.jpgSupported features (per ImageBoss docs)
- Operations:
cover,width,height,cdn - Cover modes:
mode: :center,:north,:entropy,:attention,:face,:smart,:contain,:inside, etc. - Options (any doc option via
options: { ... }):grayscale,blur,animation,download,wmk-path,withoutEnlargement,ignoreAspectRatio,fp-x,fp-y,fp-z,face-index,fill-color,format:auto, and all filters (extract, privacy, sharpen, trim, gamma, linear, threshold).
Full reference: Official Docs.
If you are coding on test, development environments and don't want to send any image to ImageBoss
you can always disable the URL generation and the client will just fallback to the original path provided.
client = ImageBoss::Client.new(source: 'mywebsite', enabled: false)
image_url = client.path('/images/img01.jpg')
.operation(:width, width: 100, options: { grayscale: true })
#=> /images/img01.jpgThis will give you the ability to see your image without adding extra code to handle this situation.
Read more: Security (signed URLs)
client = ImageBoss::Client.new(source: 'mywebsite', secret: '<MY_SECRET>')
image_url = client.path('/images/img01.jpg')
.operation(:width, width: 100)
#=> https://img.imageboss.me/width/100/images/img01.jpg?bossToken=ff74a46c7228ee4262c39b8d501c488293c5be9d433bb9ca957f32c9c3d844abThis will give you the ability to see your image without adding extra code to handle this situation.
