instance method read_image

Ruby on Rails 8.1.2

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 29
      def read_image
        unless VIPS_AVAILABLE
          logger.error "Skipping image analysis because the ruby-vips gem isn't installed"
          return {}
        end

        download_blob_to_tempfile do |file|
          image = instrument("vips") do
            # ruby-vips will raise Vips::Error if it can't find an appropriate loader for the file
            ::Vips::Image.new_from_file(file.path, access: :sequential)
          rescue ::Vips::Error
            logger.info "Skipping image analysis because Vips doesn't support the file"
            nil
          end

          if image
            yield image
          else
            {}
          end
        rescue ::Vips::Error => error
          logger.error "Skipping image analysis due to a Vips error: #{error.message}"
          {}
        end
      rescue ::Vips::Error => error
        logger.error "Skipping image analysis due to an Vips error: #{error.message}"
        {}
      end

Defined in activestorage/lib/active_storage/analyzer/image_analyzer/vips.rb line 29 · 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