chunky_png 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/BENCHMARKING.md +38 -0
- data/CONTRIBUTING.md +50 -0
- data/LICENSE +1 -1
- data/chunky_png.gemspec +12 -12
- data/lib/chunky_png/canvas/operations.rb +1 -1
- data/lib/chunky_png/color.rb +7 -7
- data/lib/chunky_png/dimension.rb +16 -15
- data/lib/chunky_png/version.rb +1 -1
- data/spec/chunky_png/canvas/adam7_interlacing_spec.rb +24 -24
- data/spec/chunky_png/canvas/data_url_exporting_spec.rb +2 -2
- data/spec/chunky_png/canvas/data_url_importing_spec.rb +4 -4
- data/spec/chunky_png/canvas/drawing_spec.rb +60 -60
- data/spec/chunky_png/canvas/masking_spec.rb +15 -15
- data/spec/chunky_png/canvas/operations_spec.rb +69 -66
- data/spec/chunky_png/canvas/png_decoding_spec.rb +26 -26
- data/spec/chunky_png/canvas/png_encoding_spec.rb +74 -74
- data/spec/chunky_png/canvas/resampling_spec.rb +47 -47
- data/spec/chunky_png/canvas/stream_exporting_spec.rb +20 -20
- data/spec/chunky_png/canvas/stream_importing_spec.rb +3 -3
- data/spec/chunky_png/canvas_spec.rb +95 -92
- data/spec/chunky_png/color_spec.rb +151 -151
- data/spec/chunky_png/datastream_spec.rb +6 -6
- data/spec/chunky_png/dimension_spec.rb +15 -15
- data/spec/chunky_png/image_spec.rb +4 -4
- data/spec/chunky_png/point_spec.rb +25 -25
- data/spec/chunky_png/rmagick_spec.rb +4 -4
- data/spec/chunky_png/vector_spec.rb +39 -34
- data/spec/chunky_png_spec.rb +1 -2
- data/spec/png_suite_spec.rb +38 -38
- data/spec/spec_helper.rb +14 -10
- metadata +37 -33
- data/BENCHMARKS.rdoc +0 -31
data/spec/spec_helper.rb
CHANGED
@@ -3,15 +3,15 @@ require 'bundler/setup'
|
|
3
3
|
require 'chunky_png'
|
4
4
|
|
5
5
|
module PNGSuite
|
6
|
-
|
6
|
+
|
7
7
|
def png_suite_file(kind, file)
|
8
8
|
File.join(png_suite_dir(kind), file)
|
9
9
|
end
|
10
|
-
|
10
|
+
|
11
11
|
def png_suite_dir(kind)
|
12
12
|
File.expand_path("./png_suite/#{kind}", File.dirname(__FILE__))
|
13
13
|
end
|
14
|
-
|
14
|
+
|
15
15
|
def png_suite_files(kind, pattern = '*.png')
|
16
16
|
Dir[File.join(png_suite_dir(kind), pattern)]
|
17
17
|
end
|
@@ -19,25 +19,25 @@ end
|
|
19
19
|
|
20
20
|
|
21
21
|
module ResourceFileHelper
|
22
|
-
|
22
|
+
|
23
23
|
def resource_file(name)
|
24
24
|
File.expand_path("./resources/#{name}", File.dirname(__FILE__))
|
25
|
-
end
|
26
|
-
|
25
|
+
end
|
26
|
+
|
27
27
|
def resource_data(name)
|
28
28
|
data = nil
|
29
|
-
File.open(resource_file(name), 'rb') { |f| data = f.read }
|
29
|
+
File.open(resource_file(name), 'rb') { |f| data = f.read }
|
30
30
|
data
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def reference_canvas(name)
|
34
34
|
ChunkyPNG::Canvas.from_file(resource_file("#{name}.png"))
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def reference_image(name)
|
38
38
|
ChunkyPNG::Image.from_file(resource_file("#{name}.png"))
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def display(png)
|
42
42
|
filename = resource_file('_tmp.png')
|
43
43
|
png.save(filename)
|
@@ -49,4 +49,8 @@ RSpec.configure do |config|
|
|
49
49
|
config.extend PNGSuite
|
50
50
|
config.include PNGSuite
|
51
51
|
config.include ResourceFileHelper
|
52
|
+
|
53
|
+
config.expect_with :rspec do |c|
|
54
|
+
c.syntax = [:should, :expect]
|
55
|
+
end
|
52
56
|
end
|
metadata
CHANGED
@@ -1,68 +1,72 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chunky_png
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Willem van Bergen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
41
|
-
description:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
40
|
+
version: '3'
|
41
|
+
description: |2
|
42
|
+
This pure Ruby library can read and write PNG images without depending on an external
|
43
|
+
image library, like RMagick. It tries to be memory efficient and reasonably fast.
|
44
|
+
|
45
|
+
It supports reading and writing all PNG variants that are defined in the specification,
|
46
|
+
with one limitation: only 8-bit color depth is supported. It supports all transparency,
|
47
|
+
interlacing and filtering options the PNG specifications allows. It can also read and
|
48
|
+
write textual metadata from PNG files. Low-level read/write access to PNG chunks is
|
49
|
+
also possible.
|
50
|
+
|
51
|
+
This library supports simple drawing on the image canvas and simple operations like
|
52
|
+
alpha composition and cropping. Finally, it can import from and export to RMagick for
|
53
|
+
interoperability.
|
54
|
+
|
55
|
+
Also, have a look at OilyPNG at http://github.com/wvanbergen/oily_png. OilyPNG is a
|
56
|
+
drop in mixin module that implements some of the ChunkyPNG algorithms in C, which
|
57
|
+
provides a massive speed boost to encoding and decoding.
|
54
58
|
email:
|
55
59
|
- willem@railsdoctors.com
|
56
60
|
executables: []
|
57
61
|
extensions: []
|
58
62
|
extra_rdoc_files:
|
59
63
|
- README.rdoc
|
60
|
-
- BENCHMARKS.rdoc
|
61
64
|
files:
|
62
|
-
- .gitignore
|
63
|
-
- .travis.yml
|
64
|
-
- .yardopts
|
65
|
-
-
|
65
|
+
- ".gitignore"
|
66
|
+
- ".travis.yml"
|
67
|
+
- ".yardopts"
|
68
|
+
- BENCHMARKING.md
|
69
|
+
- CONTRIBUTING.md
|
66
70
|
- Gemfile
|
67
71
|
- LICENSE
|
68
72
|
- README.rdoc
|
@@ -384,27 +388,27 @@ licenses:
|
|
384
388
|
metadata: {}
|
385
389
|
post_install_message:
|
386
390
|
rdoc_options:
|
387
|
-
- --title
|
391
|
+
- "--title"
|
388
392
|
- chunky_png
|
389
|
-
- --main
|
393
|
+
- "--main"
|
390
394
|
- README.rdoc
|
391
|
-
- --line-numbers
|
392
|
-
- --inline-source
|
395
|
+
- "--line-numbers"
|
396
|
+
- "--inline-source"
|
393
397
|
require_paths:
|
394
398
|
- lib
|
395
399
|
required_ruby_version: !ruby/object:Gem::Requirement
|
396
400
|
requirements:
|
397
|
-
- -
|
401
|
+
- - ">="
|
398
402
|
- !ruby/object:Gem::Version
|
399
403
|
version: '0'
|
400
404
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
401
405
|
requirements:
|
402
|
-
- -
|
406
|
+
- - ">="
|
403
407
|
- !ruby/object:Gem::Version
|
404
408
|
version: '0'
|
405
409
|
requirements: []
|
406
410
|
rubyforge_project:
|
407
|
-
rubygems_version: 2.
|
411
|
+
rubygems_version: 2.2.2
|
408
412
|
signing_key:
|
409
413
|
specification_version: 4
|
410
414
|
summary: Pure ruby library for read/write, chunk-level access to PNG files
|
data/BENCHMARKS.rdoc
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
= ChunkyPNG benchmark suite
|
2
|
-
|
3
|
-
This small benchmark suite is intended to test the speed of PNG decoding
|
4
|
-
and encoding against different ruby interpreters. You can set the number
|
5
|
-
of runs by passing the N environment variable. You can execute them as
|
6
|
-
rake task or as standalone script.
|
7
|
-
|
8
|
-
rake benchmark:encoding
|
9
|
-
rake benchmark:decoding
|
10
|
-
|
11
|
-
rake benchmark N=10 # Run all of them, using n=10
|
12
|
-
|
13
|
-
Use rvm to simply run the tests against different interpreters. Of course,
|
14
|
-
make sure that the chunky_png is installed for all your interpreters.
|
15
|
-
|
16
|
-
rvm 1.8.7,1.9.3,rbx rake benchmark N=10
|
17
|
-
|
18
|
-
== Results
|
19
|
-
|
20
|
-
Some of my benchmark (N=50) result on my 2007 iMac can be found in this gist:
|
21
|
-
http://gist.github.com/495323
|
22
|
-
|
23
|
-
== Why is this relevant?
|
24
|
-
|
25
|
-
ChunkyPNG is a pure Ruby library to handle PNG files. Decoding a PNG requires
|
26
|
-
a lot of integer math and bitwise operations, and moderate use of the unpack
|
27
|
-
method to read binary data. Encoding is a good test for Array#pack, and
|
28
|
-
depending on the encoding options, also requires a lot of calculations.
|
29
|
-
Therefore, the library is a good benchmark candidate for these methods and
|
30
|
-
algorithms. It has been used to improve the Array#pack and String#unpack
|
31
|
-
methods in Rubinius.
|