local-fastimage 3.0.1 → 3.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -8
- data/CHANGELOG.md +9 -0
- data/README.md +2 -0
- data/lib/fastimage.rb +32 -18
- data/lib/fastimage/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 576d4b3064f11a71c592f96929d6f58cb13af056
|
4
|
+
data.tar.gz: c221b3a5ed155f1f543f9d9de10ac103bd5338b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cced0adefb5b8523de34918baa5ded500e46cb72ec0208e0f5914e3074ef0a877f60b66083c9a52c7edfa0af7e637f9ff2dda0de7e255bb52dfa1d2b18ef2661
|
7
|
+
data.tar.gz: 3430d92ceb8e480625f2e506b7ed487ecff9944906e4d387d6240b2cf7adcf022d650a5a90d2e80002846cea841f1c1df0493ebb9de824910fb8a816f2104df8
|
data/.travis.yml
CHANGED
@@ -1,12 +1,11 @@
|
|
1
1
|
language: ruby
|
2
2
|
rvm:
|
3
|
-
- 1.9
|
4
|
-
-
|
5
|
-
- 2.
|
6
|
-
- 2.1.8
|
7
|
-
- 2.2.4
|
8
|
-
- 2.3.0
|
3
|
+
- 2.1.9
|
4
|
+
- 2.2.5
|
5
|
+
- 2.3.1
|
9
6
|
|
7
|
+
before_install:
|
8
|
+
- gem install bundler
|
9
|
+
|
10
|
+
cache: bundler
|
10
11
|
sudo: false
|
11
|
-
# uncomment this line if your project needs to run something other than `rake`:
|
12
|
-
# script: bundle exec rspec spec
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
# 3.0.2 - 2016-10-17
|
2
|
+
|
3
|
+
Fixes a bug,
|
4
|
+
|
5
|
+
* where local-fastimage would keep large amounts of data in memory
|
6
|
+
* where unknown file type was not reported correctly (#1)
|
7
|
+
|
8
|
+
Thanks @bertg and @sdsykes for contributing to this release
|
9
|
+
|
1
10
|
# 3.0.1 - 2016-06-02
|
2
11
|
|
3
12
|
Updating meta data in gemspec, no code changes.
|
data/README.md
CHANGED
@@ -7,6 +7,8 @@ It features the following differences:
|
|
7
7
|
* Removal of all remote image handling code
|
8
8
|
* Minor changes to code organization
|
9
9
|
|
10
|
+
[![Build Status](https://travis-ci.org/planio-gmbh/local-fastimage.svg?branch=master)](https://travis-ci.org/planio-gmbh/local-fastimage)
|
11
|
+
|
10
12
|
## Installation
|
11
13
|
|
12
14
|
Add this line to your application's Gemfile:
|
data/lib/fastimage.rb
CHANGED
@@ -276,6 +276,24 @@ class FastImage
|
|
276
276
|
@pos += n
|
277
277
|
result
|
278
278
|
end
|
279
|
+
|
280
|
+
def skip(n)
|
281
|
+
discarded = 0
|
282
|
+
fetched = @str[@strpos..-1].size
|
283
|
+
while n > fetched
|
284
|
+
discarded += @str[@strpos..-1].size
|
285
|
+
new_string = @read_fiber.resume
|
286
|
+
raise CannotParseImage if !new_string
|
287
|
+
|
288
|
+
new_string.force_encoding("ASCII-8BIT") if String.method_defined? :force_encoding
|
289
|
+
|
290
|
+
fetched += new_string.size
|
291
|
+
@str = new_string
|
292
|
+
@strpos = 0
|
293
|
+
end
|
294
|
+
@strpos = @strpos + n - discarded
|
295
|
+
@pos += n
|
296
|
+
end
|
279
297
|
end
|
280
298
|
|
281
299
|
class IOStream < SimpleDelegator # :nodoc:
|
@@ -283,7 +301,7 @@ class FastImage
|
|
283
301
|
end
|
284
302
|
|
285
303
|
def parse_type
|
286
|
-
case @stream.peek(2)
|
304
|
+
parsed_type = case @stream.peek(2)
|
287
305
|
when "BM"
|
288
306
|
:bmp
|
289
307
|
when "GI"
|
@@ -303,21 +321,13 @@ class FastImage
|
|
303
321
|
when 2 then :cur
|
304
322
|
end
|
305
323
|
when "RI"
|
306
|
-
if @stream.peek(12)[8..11] == "WEBP"
|
307
|
-
:webp
|
308
|
-
else
|
309
|
-
raise UnknownImageType
|
310
|
-
end
|
324
|
+
:webp if @stream.peek(12)[8..11] == "WEBP"
|
311
325
|
when "<s", "<?"
|
312
326
|
# Does not handle UTF-16 or other multi-byte encodings
|
313
|
-
if @stream.peek(64).include?("<svg")
|
314
|
-
:svg
|
315
|
-
else
|
316
|
-
raise UnknownImageType
|
317
|
-
end
|
318
|
-
else
|
319
|
-
raise UnknownImageType
|
327
|
+
:svg if @stream.peek(64).include?("<svg")
|
320
328
|
end
|
329
|
+
|
330
|
+
parsed_type or raise UnknownImageType
|
321
331
|
end
|
322
332
|
|
323
333
|
def parse_size_for_ico
|
@@ -339,7 +349,7 @@ class FastImage
|
|
339
349
|
loop do
|
340
350
|
@state = case @state
|
341
351
|
when nil
|
342
|
-
@stream.
|
352
|
+
@stream.skip(2)
|
343
353
|
:started
|
344
354
|
when :started
|
345
355
|
@stream.read_byte == 0xFF ? :sof : :started
|
@@ -365,10 +375,10 @@ class FastImage
|
|
365
375
|
end
|
366
376
|
when :skipframe
|
367
377
|
skip_chars = @stream.read_int - 2
|
368
|
-
@stream.
|
378
|
+
@stream.skip(skip_chars)
|
369
379
|
:started
|
370
380
|
when :readsize
|
371
|
-
@stream.
|
381
|
+
@stream.skip(3)
|
372
382
|
height = @stream.read_int
|
373
383
|
width = @stream.read_int
|
374
384
|
width, height = height, width if @exif && @exif.rotated?
|
@@ -412,7 +422,7 @@ class FastImage
|
|
412
422
|
end
|
413
423
|
|
414
424
|
def parse_size_vp8l
|
415
|
-
@stream.
|
425
|
+
@stream.skip(1) # 0x2f
|
416
426
|
b1, b2, b3, b4 = @stream.read(4).bytes.to_a
|
417
427
|
[1 + (((b2 & 0x3f) << 8) | b1), 1 + (((b4 & 0xF) << 10) | (b3 << 2) | ((b2 & 0xC0) >> 6))]
|
418
428
|
end
|
@@ -485,7 +495,11 @@ class FastImage
|
|
485
495
|
@stream.read(2) # 42
|
486
496
|
|
487
497
|
offset = @stream.read(4).unpack(@long)[0]
|
488
|
-
@stream.
|
498
|
+
if @stream.respond_to?(:skip)
|
499
|
+
@stream.skip(offset - 8)
|
500
|
+
else
|
501
|
+
@stream.read(offset - 8)
|
502
|
+
end
|
489
503
|
|
490
504
|
parse_exif_ifd
|
491
505
|
|
data/lib/fastimage/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: local-fastimage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stephen Sykes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-10-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -94,7 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
94
94
|
version: '0'
|
95
95
|
requirements: []
|
96
96
|
rubyforge_project:
|
97
|
-
rubygems_version: 2.
|
97
|
+
rubygems_version: 2.5.1
|
98
98
|
signing_key:
|
99
99
|
specification_version: 4
|
100
100
|
summary: Local FastImage - Image info fast
|