lib/fleximage/model.rb
# Load the image from disk/DB, or return the cached and potentially 
# processed output image.
Load the image from disk/DB, or return the cached and potentially
processed output image.
Load the image from disk / DB or return the cached and potentially processed output image .
def load_image 
        @output_image ||= @uploaded_image
        return @output_image if @output_image
        if self.class.db_store?
          if image_file_data && image_file_data.present?
            @output_image = Magick::Image.from_blob(image_file_data).first
          end
        elsif self.class.s3_store?
          filename = "#{id}.#{self.class.image_storage_format}"
          bucket   = self.class.s3_bucket
          if AWS::S3::S3Object.exists?(filename, bucket)
            @output_image = Magick::Image.from_blob(AWS::S3::S3Object.value(filename, bucket)).first
          end
        else
          @output_image = Magick::Image.read(file_path).first
        end
        if @output_image
          @output_image
        else
          master_image_not_found
        end
      rescue Magick::ImageMagickError => e
        if e.to_s =~ /unable to open (file|image)/
          master_image_not_found
        else
          raise e
        end
      end
def load_image @output_image ||= @uploaded_image return @output_image if @output_image if self . class . db_store? if image_file_data && image_file_data . present? @output_image = Magick :: Image . from_blob ( image_file_data ) . first end elsif self . class . s3_store? filename = "#{id}.#{self.class.image_storage_format}" bucket = self . class . s3_bucket if AWS :: S3 :: S3Object . exists? ( filename , bucket ) @output_image = Magick :: Image . from_blob ( AWS :: S3 :: S3Object . value ( filename , bucket ) ) . first end else @output_image = Magick :: Image . read ( file_path ) . first end if @output_image @output_image else master_image_not_found end rescue Magick :: ImageMagickError => e if e . to_s =~ / unable to open (file|image) / master_image_not_found else raise e end end
Load the image from disk/DB, or return the cached and potentially
processed output image.
Load the image from disk / DB or return the cached and potentially processed output image .
#:nodoc: # Return the current image if we have loaded it already # Load the image from disk # Load the image from the database column # Load image from S3 # Load the image from the disk