fastimage 2.2.6 → 2.2.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d7667683a4bbc8ac16d583fb3ed7c93e6a58a25c19bf8df909ab7dae8d4ef782
4
- data.tar.gz: 0baf5dcf6af104d0edd38baf65b7b35c972e6fc4271363d52855071e22b97a82
3
+ metadata.gz: 0365d74877c5c9bb640ef13fb701665b8fc511027ceba510be2cec62de03584c
4
+ data.tar.gz: d15af188ae269215bce75d21d1f796680bd66a488367ab9a935919b50fe10a68
5
5
  SHA512:
6
- metadata.gz: 9261157ade925ba5be4761028b4d70a698f1cc4d54e4ef0fcb7f4b23b6120ae6f9c42516b0dc17f915c423d168a4ef66c805a686ea20e3ca311556ce3e930593
7
- data.tar.gz: 2d319a0aa6c4e7c7a3d951b3025d6215ac999bc2efe5d054720dac9c063cb3e2939e35e30660cf360bfae5f88285b91bb8029ec594c64ca1eb9e3e4144fa6b4c
6
+ metadata.gz: e9b26747ff490133917388f29203c1d8272dfe88c28b9a5208a3df1a55728779c3cfe203784c6df9d1bca91bcf58df0cf64e60220a468a0c9f6ca4f47963b3e0
7
+ data.tar.gz: aa8f0a007f6cb710cbcea70241a56b9fd98fd54bb1a553be7c5533fca7b125b7df99ffbf5dcf5e996d87f60eb8a83933fd49aba848fc4a93c85ac540c8ae1577
data/README.textile CHANGED
@@ -1,5 +1,5 @@
1
1
  !https://img.shields.io/gem/dt/fastimage.svg!:https://rubygems.org/gems/fastimage
2
- !https://travis-ci.org/sdsykes/fastimage.svg?branch=master!:https://travis-ci.org/sdsykes/fastimage
2
+ !https://github.com/sdsykes/fastimage/actions/workflows/test.yml/badge.svg?branch=master!:https://github.com/sdsykes/fastimage/actions/workflows/test.yml
3
3
 
4
4
  h1. FastImage
5
5
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastImage
4
- VERSION = '2.2.6'
4
+ VERSION = '2.2.7'
5
5
  end
data/lib/fastimage.rb CHANGED
@@ -85,6 +85,8 @@ class FastImage
85
85
  end
86
86
  class CannotParseImage < FastImageException # :nodoc:
87
87
  end
88
+ class BadImageURI < FastImageException # :nodoc:
89
+ end
88
90
 
89
91
  DefaultTimeout = 2 unless const_defined?(:DefaultTimeout)
90
92
 
@@ -228,6 +230,8 @@ class FastImage
228
230
  :size
229
231
  end
230
232
 
233
+ raise BadImageURI if uri.nil?
234
+
231
235
  @type, @state = nil
232
236
 
233
237
  if uri.respond_to?(:read)
@@ -254,7 +258,7 @@ class FastImage
254
258
  Errno::ENETUNREACH, ImageFetchFailure, Net::HTTPBadResponse, EOFError, Errno::ENOENT,
255
259
  OpenSSL::SSL::SSLError
256
260
  raise ImageFetchFailure if @options[:raise_on_failure]
257
- rescue UnknownImageType
261
+ rescue UnknownImageType, BadImageURI
258
262
  raise if @options[:raise_on_failure]
259
263
  rescue CannotParseImage
260
264
  if @options[:raise_on_failure]
@@ -431,7 +435,7 @@ class FastImage
431
435
 
432
436
  def parse_animated
433
437
  @type = parse_type unless @type
434
- @type == :gif ? send("parse_animated_for_#{@type}") : nil
438
+ %i(gif webp avif).include?(@type) ? send("parse_animated_for_#{@type}") : nil
435
439
  end
436
440
 
437
441
  def fetch_using_base64(uri)
@@ -547,6 +551,8 @@ class FastImage
547
551
  case @stream.peek(12)[4..-1]
548
552
  when "ftypavif"
549
553
  :avif
554
+ when "ftypavis"
555
+ :avif
550
556
  when "ftypheic"
551
557
  :heic
552
558
  when "ftypmif1"
@@ -1088,4 +1094,24 @@ class FastImage
1088
1094
  gif = Gif.new(@stream)
1089
1095
  gif.animated?
1090
1096
  end
1097
+
1098
+ def parse_animated_for_webp
1099
+ vp8 = @stream.read(16)[12..15]
1100
+ _len = @stream.read(4).unpack("V")
1101
+ case vp8
1102
+ when "VP8 "
1103
+ false
1104
+ when "VP8L"
1105
+ false
1106
+ when "VP8X"
1107
+ flags = @stream.read(4).unpack("C")[0]
1108
+ flags & 2 > 0
1109
+ else
1110
+ nil
1111
+ end
1112
+ end
1113
+
1114
+ def parse_animated_for_avif
1115
+ @stream.peek(12)[4..-1] == "ftypavis"
1116
+ end
1091
1117
  end
metadata CHANGED
@@ -1,11 +1,11 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fastimage
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.6
4
+ version: 2.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Sykes
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
  date: 2021-02-28 00:00:00.000000000 Z
@@ -82,7 +82,7 @@ homepage: http://github.com/sdsykes/fastimage
82
82
  licenses:
83
83
  - MIT
84
84
  metadata: {}
85
- post_install_message:
85
+ post_install_message:
86
86
  rdoc_options:
87
87
  - "--charset=UTF-8"
88
88
  require_paths:
@@ -98,8 +98,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  - !ruby/object:Gem::Version
99
99
  version: '0'
100
100
  requirements: []
101
- rubygems_version: 3.1.6
102
- signing_key:
101
+ rubygems_version: 3.4.6
102
+ signing_key:
103
103
  specification_version: 4
104
104
  summary: FastImage - Image info fast
105
105
  test_files: []