Class: JekyllImgFlow::AnimatedGifDetector
- Inherits:
-
Object
- Object
- JekyllImgFlow::AnimatedGifDetector
- Defined in:
- lib/jekyll-imgflow/animated_gif_detector.rb
Overview
Detects whether a GIF file is animated (contains multiple frames)
Animated GIFs must not be resized or format-converted because the operation would destroy the animation. This class parses the GIF binary format and counts Image Descriptor blocks to determine whether more than one frame is present.
Constant Summary collapse
- EXTENSION_INTRODUCER =
GIF block introducer bytes
0x21- IMAGE_DESCRIPTOR =
0x2C- TRAILER =
0x3B
Class Method Summary collapse
-
.animated?(path) ⇒ Boolean
Check whether the file at
pathis an animated GIF.
Instance Method Summary collapse
- #animated? ⇒ Boolean
-
#initialize(path) ⇒ AnimatedGifDetector
constructor
A new instance of AnimatedGifDetector.
Constructor Details
#initialize(path) ⇒ AnimatedGifDetector
Returns a new instance of AnimatedGifDetector.
25 26 27 |
# File 'lib/jekyll-imgflow/animated_gif_detector.rb', line 25 def initialize(path) @path = path end |
Class Method Details
.animated?(path) ⇒ Boolean
Check whether the file at path is an animated GIF.
20 21 22 |
# File 'lib/jekyll-imgflow/animated_gif_detector.rb', line 20 def self.animated?(path) new(path).animated? end |
Instance Method Details
#animated? ⇒ Boolean
29 30 31 32 33 |
# File 'lib/jekyll-imgflow/animated_gif_detector.rb', line 29 def animated? return false unless gif? frame_count > 1 end |