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

- old
+ new

@@ -1,10 +1,10 @@ require "fileutils" require "tempfile" class Imagery - VERSION = "0.2.0" + VERSION = "0.2.1" autoload :S3, "imagery/s3" autoload :Faking, "imagery/faking" autoload :Test, "imagery/test" @@ -144,21 +144,27 @@ system(sprintf(CONVERT, dim(resize), src, resize, extent(extent), dst)) end def self.identify(io) file = Tempfile.new("imagery") + + # 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` return $?.success? ensure # Very important, else `io.read` will return "". io.rewind # Tempfile quickly runs out of names, so best to avoid that. - file.unlink + file.close! end # Return the cleaned dimension representation minus the # geometry directives. def self.dim(dim)