Module: ImageProcessing::MiniMagick::DeprecatedApi::Utils

Defined in:
lib/image_processing/mini_magick/deprecated_api.rb

Class Method Summary collapse

Class Method Details

.copy_to_tempfile(io) ⇒ Object



103
104
105
106
107
108
109
110
111
112
113
114
115
# File 'lib/image_processing/mini_magick/deprecated_api.rb', line 103

def copy_to_tempfile(io)
  extension = File.extname(io.path) if io.respond_to?(:path)
  tempfile  = Tempfile.new(["image_processing", extension.to_s], binmode: true)

  IO.copy_stream(io, tempfile)

  io.rewind
  tempfile.open # refresh content

  yield tempfile
ensure
  tempfile.close! if tempfile
end