Module: ActiveStorage::Blurhash::Analyzing
- Included in:
- ActiveStorage::Blurhash::Analyzer::ImageMagick, ActiveStorage::Blurhash::Analyzer::Vips
- Defined in:
- lib/active_storage/blurhash/analyzing.rb
Instance Attribute Summary collapse
-
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
Instance Method Summary collapse
Instance Attribute Details
#thumbnail ⇒ Object
Returns the value of attribute thumbnail.
6 7 8 |
# File 'lib/active_storage/blurhash/analyzing.rb', line 6 def thumbnail @thumbnail end |
Instance Method Details
#blurhash ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/active_storage/blurhash/analyzing.rb', line 16 def blurhash { blurhash: ::Blurhash.encode( thumbnail.width, thumbnail.height, thumbnail.pixels ) } end |
#build_thumbnail(image) ⇒ Object
26 27 28 29 |
# File 'lib/active_storage/blurhash/analyzing.rb', line 26 def build_thumbnail(image) # we scale down the image for faster blurhash processing @thumbnail ||= "ActiveStorage::Blurhash::Thumbnail::#{processor}".constantize.new(image) end |
#metadata ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/active_storage/blurhash/analyzing.rb', line 8 def # we could also re-implement #metadata, so that the image is only read once, but it's much less DRY read_image do |image| build_thumbnail(image) super.merge blurhash end end |