lib/paperclip/thumbnail.rb in paperclip-3.0.4 vs lib/paperclip/thumbnail.rb in paperclip-3.1.0
- old
+ new
@@ -96,9 +96,18 @@
protected
# Return true if the format is animated
def animated?
- @animated && ANIMATED_FORMATS.include?(@current_format[1..-1]) && (ANIMATED_FORMATS.include?(@format.to_s) || @format.blank?)
+ @animated && (ANIMATED_FORMATS.include?(@format.to_s) || @format.blank?) && identified_as_animated?
+ end
+
+ # Return true if ImageMagick's +identify+ returns an animated format
+ def identified_as_animated?
+ ANIMATED_FORMATS.include? identify("-format %m :file", :file => "#{@file.path}[0]").to_s.downcase.strip
+ rescue Cocaine::ExitStatusError => e
+ raise Paperclip::Error, "There was an error running `identify` for #{@basename}" if @whiny
+ rescue Cocaine::CommandNotFoundError => e
+ raise Paperclip::Errors::CommandNotFoundError.new("Could not run the `identify` command. Please install ImageMagick.")
end
end
end