igorkasyanchuk/active_storage_validations

Refactor the `metadata.rb` from `ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick/Vips.new(blob).metadata`

Closed this issue · 0 comments

Reading Rails documentation to implement a feature for this gem, I came across the following ActiveStorage class: https://github.com/rails/rails/blob/55c4adeb36eff229972eecbb53723c1b80393091/activestorage/lib/active_storage/analyzer/image_analyzer.rb

It looks like it both supports MiniMagick and Vips since June 2021. The metadata.rb file however was built a few years before maybe explaining its presence?

We could rely on ActiveStorage::Analyzer::ImageAnalyzers to do this job, therefore decreasing the weight + associated unnecessary complexity of this gem?

UPDATE : We can't rely on ActiveStorage::Analyzer::ImageAnalyzers to do this job because it needs a saved blob, ie with its io uploaded. We only have not uploaded attachables at this point, but we can copy their structure to refactor metadata.rb (which could be a very nice addition)

@igorkasyanchuk @gr8bit what do you think of it?