instance method read_image

Ruby on Rails 7.0.10

Since v7.0.10 Private

Available in: v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

read_image()

No documentation comment.

Source
# File activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb, line 12
      def read_image
        begin
          require "ruby-vips"
        rescue LoadError
          logger.info "Skipping image analysis because the ruby-vips gem isn't installed"
          return {}
        end

        download_blob_to_tempfile do |file|
          image = instrument("vips") do
            ::Vips::Image.new_from_file(file.path, access: :sequential)
          end

          if valid_image?(image)
            yield image
          else
            logger.info "Skipping image analysis because Vips doesn't support the file"
            {}
          end
        rescue ::Vips::Error => error
          logger.error "Skipping image analysis due to an Vips error: #{error.message}"
          {}
        end
      end

Defined in activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb line 12 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveStorage::Analyzer::ImageAnalyzer::Vips

Type at least 2 characters to search.

↑↓ navigate · open · esc close