lib/imagery.rb in imagery-0.2.1 vs lib/imagery.rb in imagery-0.2.2

- old
+ new

@@ -1,10 +1,10 @@ require "fileutils" require "tempfile" class Imagery - VERSION = "0.2.1" + VERSION = "0.2.2" autoload :S3, "imagery/s3" autoload :Faking, "imagery/faking" autoload :Test, "imagery/test" @@ -143,28 +143,29 @@ def self.convert(src, dst, resize, extent = nil) system(sprintf(CONVERT, dim(resize), src, resize, extent(extent), dst)) end def self.identify(io) - file = Tempfile.new("imagery") + file = Tempfile.new(["imagery", ".jpg"]) # Something poorly documented, but vastly important: we need to # make sure the file is in binary mode. file.binmode # Now we can safely write the file knowing that we're operating in # binary mode. file.write(io.read) + file.close - `gm identify #{io.path} 2> /dev/null` + `gm identify #{file.path} 2> /dev/null` return $?.success? ensure # Very important, else `io.read` will return "". io.rewind # Tempfile quickly runs out of names, so best to avoid that. - file.close! + file.unlink end # Return the cleaned dimension representation minus the # geometry directives. def self.dim(dim)