Skip to content

imageboss/imageboss-rb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ImageBoss logo

ImageBoss Helper for Ruby

CI Gem Version

Official Gem for Generating ImageBoss URLs. https://imageboss.me/

Table of Contents

Ruby compatibility

  • 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).

Installation

Add this line to your application's Gemfile:

bundle add imageboss-rb

Or install it yourself as:

gem install imageboss-rb

Usage

Example Image Resizing With Cover Operation

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.jpg

Example Image Resizing With Height Operation

client = 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.jpg

Example Image Resizing With Extra Options

client = 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.jpg

Supported 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).

All operations and options for Image Resizing

Full reference: Official Docs.

Disabling URL generation

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.jpg

This will give you the ability to see your image without adding extra code to handle this situation.

Signing your URLs

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=ff74a46c7228ee4262c39b8d501c488293c5be9d433bb9ca957f32c9c3d844ab

This will give you the ability to see your image without adding extra code to handle this situation.

About

Ruby Integration for ImageBoss

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages