Sha256: 710d821ba31d67789ce89c7b3e9a8952bc54ef47b1f02c95f8c58d6b4bdb8fcd
Contents?: true
Size: 1.23 KB
Versions: 2
Compression:
Stored size: 1.23 KB
Contents
module Riiif class File attr_reader :path class_attribute :info_extractor_class self.info_extractor_class = ImageMagickInfoExtractor # @param input_path [String] The location of an image file def initialize(input_path, tempfile = nil) @path = input_path @tempfile = tempfile # ensures that the tempfile will stick around until this file is garbage collected. end def self.read(stream, ext) create(ext) do |f| while chunk = stream.read(8192) f.write(chunk) end end end def self.create(ext = nil, _validate = true, &block) tempfile = Tempfile.new(['mini_magick', ext.to_s.downcase]) tempfile.binmode block.call(tempfile) tempfile.close image = new(tempfile.path, tempfile) ensure tempfile.close if tempfile end # @param [Transformation] transformation def extract(transformation) command = command_factory.build(path, transformation) execute(command) end def info @info ||= info_extractor_class.new(path).extract end delegate :execute, to: Riiif::CommandRunner private :execute private def command_factory ImagemagickCommandFactory end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
riiif-1.4.0 | app/models/riiif/file.rb |
riiif-1.3.0 | app/models/riiif/file.rb |