Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Memoize result of identify command in order to avoid multiple calls t…

…o ImageMagick
  • Loading branch information...
commit fe19916633fcd10d5429066bc60cfb2ca5992e22 1 parent c5f2b14
@adamniedzielski adamniedzielski authored jyurek committed
Showing with 4 additions and 1 deletion.
  1. +4 −1 lib/paperclip/thumbnail.rb
View
5 lib/paperclip/thumbnail.rb
@@ -109,7 +109,10 @@ def animated?
# 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
+ if @identified_as_animated.nil?
+ @identified_as_animated = ANIMATED_FORMATS.include? identify("-format %m :file", :file => "#{@file.path}[0]").to_s.downcase.strip
+ end
+ @identified_as_animated
rescue Cocaine::ExitStatusError => e
raise Paperclip::Error, "There was an error running `identify` for #{@basename}" if @whiny
rescue Cocaine::CommandNotFoundError => e
Please sign in to comment.
Something went wrong with that request. Please try again.