Repository: rails/rails
File: activestorage/lib/active_storage/engine.rb (Ruby)

Code before:
      image/gif
      image/jpeg
      image/tiff
      image/bmp
      image/vnd.adobe.photoshop
      image/vnd.microsoft.icon
      application/pdf
    )

    config.eager_load_namespaces << ActiveStorage

    initializer "active_storage.deprecator", before: :load_environment_config do |app|
      app.deprecators[:active_storage] = ActiveStorage.deprecator
    end

    initializer "active_storage.configs" do
      config.before_initialize do |app|
        ActiveStorage.touch_attachment_records = app.config.active_storage.touch_attachment_records != false
      end

      config.after_initialize do |app|
        ActiveStorage.logger            = app.config.active_storage.logger || Rails.logger
        ActiveStorage.variant_processor = app.config.active_storage.variant_processor || :mini_magick
        ActiveStorage.previewers        = app.config.active_storage.previewers || []
        begin
          ActiveStorage.analyzers = app.config.active_storage.analyzers ||
            [
              ActiveStorage::Analyzer::ImageAnalyzer::Vips,
              ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick,
              ActiveStorage::Analyzer::VideoAnalyzer,
              ActiveStorage::Analyzer::AudioAnalyzer
            ]
        rescue LoadError => error
          case error.message
          when /mini_magick/
            ActiveStorage.logger.warn <<~WARNING.squish
              Analyzing images with ImageMagick requires the mini_magick gem.
              Please add `gem 'mini_magick'` to your Gemfile.
            WARNING
          when /ruby-vips/
            ActiveStorage.logger.warn <<~WARNING.squish
              Analyzing images with Vips requires the ruby-vips gem.
              Please add `gem 'ruby-vips'` to your Gemfile.
            WARNING
          else
            raise
          end
        end

        begin
          ActiveStorage.variant_transformer =

Review comment (bug):
In the changelog you write:
> You can also disable variant processor to remove warnings on startup about missing gems.

But here the warnings are still shown if the gem is not present. Maybe something along the likes of this makes sense?

```rb
analyzers = []
begin
  analyzers += ActiveStorage::Analyzer::ImageAnalyzer::Vips
rescue LoadError
  # handle it
end
begin
  analyzers += ActiveStorage::Analyzer::ImageAnalyzer::ImageMagick
rescue LoadError
    # handle it
end
if analyzers.empty?
  # warn that both gems are missing, no image analyzing will happen
end
# Side note: These two inform you about missing deps at runtime only. They need the `ffprobe` command, can't exactly eagerly require that.
analyzers.concat(ActiveStorage::Analyzer::VideoAnalyzer, ActiveStorage::Analyzer::AudioAnalyzer)
```

I use vips for analyzing and have the necessary gem in my gemfile, but since it tries to eager-load image-magick as well in the same block, it warns and fails to use vips which I think should just work.

Code after:
      image/png
      image/gif
      image/jpeg
      image/tiff
      image/bmp
      image/vnd.adobe.photoshop
      image/vnd.microsoft.icon
      application/pdf
    )

    config.eager_load_namespaces << ActiveStorage

    initializer "active_storage.deprecator", before: :load_environment_config do |app|
      app.deprecators[:active_storage] = ActiveStorage.deprecator
    end

    initializer "active_storage.configs" do
      config.before_initialize do |app|
        ActiveStorage.touch_attachment_records = app.config.active_storage.touch_attachment_records != false
      end

      config.after_initialize do |app|
        ActiveStorage.logger            = app.config.active_storage.logger || Rails.logger
        ActiveStorage.variant_processor = app.config.active_storage.variant_processor || :mini_magick
        ActiveStorage.previewers        = app.config.active_storage.previewers || []
        ActiveStorage.analyzers         = app.config.active_storage.analyzers || []

        begin
          ActiveStorage.variant_transformer =
            case ActiveStorage.variant_processor
            when :disabled
              ActiveStorage::Transformers::NullTransformer
            when :vips
              ActiveStorage::Transformers::Vips
            when :mini_magick
              ActiveStorage::Transformers::ImageMagick
            end
        rescue LoadError => error
          case error.message
          when /libvips/
            ActiveStorage.logger.warn <<~WARNING.squish
              Using vips to process variants requires the libvips library.
              Please install libvips using the instructions on the libvips website.
            WARNING
          when /image_processing/
            ActiveStorage.logger.warn <<~WARNING.squish
              Generating image variants require the image_processing gem.
              Please add `gem 'image_processing', '~> 1.2'` to your Gemfile.
            WARNING
          else
            raise