fastimage 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.textile +1 -0
  3. data/lib/fastimage.rb +25 -18
  4. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 53c0966ef5216c189e2950b1ad36c106777175f0d4dca9851abd34472fd9cb61
4
- data.tar.gz: 29f5a6bc03623e184166e7f9c5e8c4379011b301904d4c690037d5b7b0ba0b33
3
+ metadata.gz: 72e83c6f6d442c29071e060cca8a8b0a0a17024a7871cd19a64b83f77e0c0ced
4
+ data.tar.gz: 56d0f5f86e11f1a8922cdf5bbe292fef2753f5637df402fd7532ef21d8393537
5
5
  SHA512:
6
- metadata.gz: 28e8ec4debe6c2c477da19cafb1ad41e5de4d809136bd86621ae128372c32c1259abea833856f73dfcfe8ef3444bc5e1a148f91b52ee02d3292235c4d95fc542
7
- data.tar.gz: ba8b4c6bb42146387b1a8af718fbbaf74a9a94532ee5adce082ff676095dad5d5e0eb613f1ec41d7729709847195fa81c4614f2d9d510d6c7def67f8970f168e
6
+ metadata.gz: 002eb40a04b2ce79f8cdc34ee2fdc0d70fe35ff964d380096302682756a17e4b22f8275e335822f5229080aada2ca8d5d17603607cb0cf6479b61ac6d4dd64ef
7
+ data.tar.gz: 17c8efefdc90fae00178d045bb0670e2914f9f19eabdb0be983c49ffb573b752672f02678e38b1395129d7f55ffc42905fa1cbeb9017445ffa295db6cc4fe119
@@ -156,6 +156,7 @@ h2. FastImage in other languages
156
156
  * "Node.js by ShogunPanda":https://github.com/ShogunPanda/fastimage
157
157
  * "Objective C by kylehickinson":https://github.com/kylehickinson/FastImage
158
158
  * "Android by qstumn":https://github.com/qstumn/FastImageSize
159
+ * "Flutter by ky1vstar":https://github.com/ky1vstar/fastimage.dart
159
160
 
160
161
  h2. Licence
161
162
 
@@ -578,38 +578,45 @@ class FastImage
578
578
  # Checks if a delay between frames exists and if it does, then the GIFs is
579
579
  # animated
580
580
  def animated?
581
- delay = 0
581
+ frames = 0
582
582
 
583
- @stream.read(10) # "GIF" + version (3) + width (2) + height (2)
583
+ # "GIF" + version (3) + width (2) + height (2)
584
+ @stream.skip(10)
584
585
 
585
- fields = @stream.read(3).unpack("C")[0] # fields (1) + bg color (1) + pixel ratio (1)
586
-
587
- # Skip Global Color Table if it exists
588
- if fields & 0x80
586
+ # fields (1) + bg color (1) + pixel ratio (1)
587
+ fields = @stream.read(3).unpack("CCC")[0]
588
+ if fields & 0x80 # Global Color Table
589
589
  # 2 * (depth + 1) colors, each occupying 3 bytes (RGB)
590
590
  @stream.skip(3 * 2 ** ((fields & 0x7) + 1))
591
591
  end
592
592
 
593
593
  loop do
594
594
  block_type = @stream.read(1).unpack("C")[0]
595
- if block_type == 0x21
596
- extension_type = @stream.read(1).unpack("C")[0]
597
- size = @stream.read(1).unpack("C")[0]
598
- if extension_type == 0xF9
599
- delay = @stream.read(4).unpack("CSC")[1] # fields (1) + delay (2) + transparent index (1)
600
- break
601
- elsif extension_type == 0xFF
602
- @stream.skip(size) # application ID (8) + version (3)
603
- else
604
- return # unrecognized extension
595
+
596
+ if block_type == 0x21 # Graphic Control Extension
597
+ # extension type (1) + size (1)
598
+ size = @stream.read(2).unpack("CC")[1]
599
+ @stream.skip(size)
600
+ skip_sub_blocks
601
+ elsif block_type == 0x2C # Image Descriptor
602
+ frames += 1
603
+ return true if frames > 1
604
+
605
+ # left position (2) + top position (2) + width (2) + height (2) + fields (1)
606
+ fields = @stream.read(9).unpack("SSSSC")[4]
607
+ if fields & 0x80 != 0 # Local Color Table
608
+ # 2 * (depth + 1) colors, each occupying 3 bytes (RGB)
609
+ @stream.skip(3 * 2 ** ((fields & 0x7) + 1))
605
610
  end
611
+
612
+ @stream.skip(1) # LZW min code size (1)
606
613
  skip_sub_blocks
607
614
  else
608
- return # unrecognized block
615
+ break # unrecognized block
609
616
  end
610
617
  end
611
618
 
612
- delay > 0
619
+ false
613
620
  end
614
621
 
615
622
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
@@ -97,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
97
  - !ruby/object:Gem::Version
98
98
  version: '0'
99
99
  requirements: []
100
- rubygems_version: 3.0.6
100
+ rubygems_version: 3.0.3
101
101
  signing_key:
102
102
  specification_version: 4
103
103
  summary: FastImage - Image info fast