A collection of active storage analyzers
Add this line to your application's Gemfile:
gem 'active_analysis'
And then execute:
$ bundle install
Active Analysis automatically replaces all of Rails default analyzers with its own. It will not remove other custom analyzers if you have them. You can also configure which analyzers will be inserted.
Rails.application.configure do |config|
config.active_analysis.image_library = :vips # Defaults to the same as active storage
config.active_analysis.image_analyzer = true # Defaults to true
config.active_analysis.audio_analyzer = true # Defaults to true
config.active_analysis.pdf_analyzer = false # Defaults to true
config.active_analysis.video_analyzer = false # Defaults to true
end
A modification of the original image analyzer and a new analyzer. Requires the ImageMagick system library or the libvips system library.
- Width (pixels)
- Height (pixels)
- Opaque (true if file is opaque, false if not)
An image will be considered opaque if it does not have an alpha channel, or if none of its pixels have an alpha value below the minimum (as defined by the library).
A new analyzer. Requires the poppler system library.
- Width (pixels)
- Height (pixels)
- Pages
A new analyzer. Requires the FFmpeg system library.
- Duration (seconds)
- Bit Rate (bits/second)
A modification of the original video analyzer. Requires the FFmpeg system library
- Width (pixels)
- Height (pixels)
- Duration (seconds)
- Angle (degrees)
- Display aspect ratio
- Audio (true if file has an audio channel, false if not)
- Video (true if file has an video channel, false if not)
Active Analysis allows additional features to be added to the image analyzers through addons. To create an addon simply inherit the Addon
class and add it to the addons array in the configuration.
Rails.application.configure do |config|
config.active_analysis.addons << ActiveAnalysis::Addon::ImageAddon::WhiteBackground
end
The following addons available:
- ImageAddon::WhiteBackground: An EXPERIMENTAL addon that checks if the image has a white background. Requires both vips and image magick to be installed.
After checking out the repo, run bin/setup
to install dependencies. Then, run rake test
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
. To release a new version, update the version number in version.rb
, and then run bundle exec rake release
, which will create a git tag for the version, push git commits and the created tag, and push the .gem
file to rubygems.org.
Bug reports and pull requests are welcome on GitHub at https://github.com/FestaLab/active_analysis. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.
The gem is available as open source under the terms of the MIT License.
Everyone interacting in the ActiveAnalysis project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.