webp-ffi 0.1.2 → 0.1.3

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.
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## v0.1.3
2
+
3
+ * Rename module to WebP
4
+
1
5
  ## v0.1.2
2
6
 
3
7
  * Added all possible encode options (also added this options in readme)
data/README.md CHANGED
@@ -45,16 +45,16 @@ Or install it yourself as:
45
45
 
46
46
  ## Usage
47
47
 
48
- ### Encode end Decoder versions
48
+ ### Encoder end Decoder versions
49
49
 
50
50
  Basic info about libwebp (encoder and decoder versions):
51
51
 
52
52
  $ irb
53
53
  2.0.0p0 :001 > require 'webp_ffi'
54
54
  => true
55
- 2.0.0p0 :002 > WebpFfi.decoder_version
55
+ 2.0.0p0 :002 > WebP.decoder_version
56
56
  => "0.2.0"
57
- 2.0.0p0 :003 > WebpFfi.encoder_version
57
+ 2.0.0p0 :003 > WebP.encoder_version
58
58
  => "0.2.0"
59
59
 
60
60
  ### WebP size (width and height)
@@ -62,7 +62,7 @@ Basic info about libwebp (encoder and decoder versions):
62
62
  Get size (width and height) from webp image:
63
63
 
64
64
  filename = File.expand_path(File.join(File.dirname(__FILE__), "spec/factories/4.webp"))
65
- WebpFfi.webp_size(File.open(filename, "rb").read)
65
+ WebP.webp_size(File.open(filename, "rb").read)
66
66
  => [2000, 2353]
67
67
 
68
68
  ### Encode png, jpg or tiff image to WebP image
@@ -71,12 +71,12 @@ Encode png, jpg or tiff image to webp:
71
71
 
72
72
  filename = File.expand_path(File.join(File.dirname(__FILE__), "spec/factories/4.png"))
73
73
  out_filename = File.expand_path(File.join(File.dirname(__FILE__), "tmp/4.webp"))
74
- WebpFfi.encode(filename, out_filename)
74
+ WebP.encode(filename, out_filename)
75
75
 
76
76
  Encode png, jpg or tiff image to webp (with options):
77
77
 
78
- WebpFfi.encode(filename, out_filename, quality: 50, resize_w: 100, resize_h: 200)
79
- WebpFfi.encode(filename, out_filename, quality: 75, crop_x: 0, cropt_y: 0, crop_w: 100, crop_h: 100)
78
+ WebP.encode(filename, out_filename, quality: 50, resize_w: 100, resize_h: 200)
79
+ WebP.encode(filename, out_filename, quality: 75, crop_x: 0, cropt_y: 0, crop_w: 100, crop_h: 100)
80
80
 
81
81
  Possible encode options:
82
82
 
@@ -109,7 +109,7 @@ Decode webp image to png:
109
109
 
110
110
  filename = File.expand_path(File.join(File.dirname(__FILE__), "spec/factories/4.webp"))
111
111
  out_filename = File.expand_path(File.join(File.dirname(__FILE__), "tmp/4.png"))
112
- WebpFfi.decode(filename, out_filename)
112
+ WebP.decode(filename, out_filename)
113
113
 
114
114
  ## Contributing
115
115
 
@@ -1,4 +1,4 @@
1
- module WebpFfi
1
+ module WebP
2
2
  module C
3
3
  # struct
4
4
  class FfiWebpEncodeConfig < FFI::Struct
@@ -1,4 +1,4 @@
1
- module WebpFfi
1
+ module WebP
2
2
 
3
3
  ENCODER_ERRORS = [
4
4
  "Version mismatch",
@@ -1,4 +1,4 @@
1
- module WebpFfi
1
+ module WebP
2
2
  module LibC
3
3
  extend FFI::Library
4
4
  # figures out the correct libc for each platform including Windows
@@ -1,4 +1,4 @@
1
- module WebpFfi
1
+ module WebP
2
2
  class Options
3
3
 
4
4
  def initialize(options)
@@ -0,0 +1,3 @@
1
+ module WebP
2
+ VERSION = "0.1.3"
3
+ end
@@ -1,7 +1,7 @@
1
- require "webp_ffi/options"
2
- require "webp_ffi/c"
1
+ require "webp/options"
2
+ require "webp/c"
3
3
 
4
- module WebpFfi
4
+ module WebP
5
5
  class << self
6
6
 
7
7
  def decoder_version
data/lib/webp_ffi.rb CHANGED
@@ -1,16 +1,16 @@
1
1
  require 'ffi'
2
2
  require 'ffi-compiler/loader'
3
3
 
4
- module WebpFfi
4
+ module WebP
5
5
  module C
6
6
  extend FFI::Library
7
7
  ffi_lib FFI::Compiler::Loader.find('webp_ffi')
8
8
  end
9
9
  end
10
10
 
11
- require "webp_ffi/options"
12
- require "webp_ffi/c"
13
- require "webp_ffi/error"
14
- require "webp_ffi/libc" # not used right now
15
- require "webp_ffi/webp_ffi"
16
- require "webp_ffi/version"
11
+ require "webp/options"
12
+ require "webp/c"
13
+ require "webp/error"
14
+ require "webp/libc" # not used right now
15
+ require "webp/webp"
16
+ require "webp/version"
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe WebpFfi do
3
+ describe WebP do
4
4
  factories = {
5
5
  webp: ["1", "2", "3", "4", "5", "6", "7"],
6
6
  png: ["1", "2", "3", "4"],
@@ -44,18 +44,18 @@ describe WebpFfi do
44
44
  end
45
45
 
46
46
  it "calculate plus 100 by test_c (verify C)" do
47
- WebpFfi::C.test_c(100).should == 200
48
- WebpFfi::C.test_c(150).should == 250
47
+ WebP::C.test_c(100).should == 200
48
+ WebP::C.test_c(150).should == 250
49
49
  end
50
50
 
51
51
  it "decoder version" do
52
- WebpFfi.decoder_version.should_not be_nil
53
- WebpFfi.decoder_version.should =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/
52
+ WebP.decoder_version.should_not be_nil
53
+ WebP.decoder_version.should =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/
54
54
  end
55
55
 
56
56
  it "encoder version" do
57
- WebpFfi.encoder_version.should_not be_nil
58
- WebpFfi.decoder_version.should =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/
57
+ WebP.encoder_version.should_not be_nil
58
+ WebP.decoder_version.should =~ /^([0-9]+)\.([0-9]+)\.([0-9]+)$/
59
59
  end
60
60
 
61
61
  context "webp_size" do
@@ -63,7 +63,7 @@ describe WebpFfi do
63
63
  it "#{image} image size == #{factories[:info][image][:size]}" do
64
64
  filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.webp"))
65
65
  data = File.open(filename, "rb").read
66
- info = WebpFfi.webp_size(data)
66
+ info = WebP.webp_size(data)
67
67
  info.class.should == Array
68
68
  info.size.should == 2
69
69
  info.should == factories[:info][image][:size]
@@ -72,7 +72,7 @@ describe WebpFfi do
72
72
  it "raise InvalidImageFormatError for non-webp image" do
73
73
  filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/1.png"))
74
74
  data = File.open(filename, "rb").read
75
- expect { WebpFfi.webp_size(data) }.to raise_error WebpFfi::InvalidImageFormatError
75
+ expect { WebP.webp_size(data) }.to raise_error WebP::InvalidImageFormatError
76
76
  end
77
77
  end
78
78
 
@@ -81,28 +81,28 @@ describe WebpFfi do
81
81
  it "#{image}.png image" do
82
82
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.png"))
83
83
  out_filename = File.expand_path(File.join(@out_dir, "#{image}.png.webp"))
84
- WebpFfi.encode(in_filename, out_filename).should be_true
84
+ WebP.encode(in_filename, out_filename).should be_true
85
85
  end
86
86
  end
87
87
  factories[:jpg].each do |image|
88
88
  it "#{image}.jpg image" do
89
89
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.jpg"))
90
90
  out_filename = File.expand_path(File.join(@out_dir, "#{image}.jpg.webp"))
91
- WebpFfi.encode(in_filename, out_filename).should be_true
91
+ WebP.encode(in_filename, out_filename).should be_true
92
92
  end
93
93
  end
94
94
  factories[:tiff].each do |image|
95
95
  it "#{image}.tif image" do
96
96
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.tif"))
97
97
  out_filename = File.expand_path(File.join(@out_dir, "#{image}.tif.webp"))
98
- WebpFfi.encode(in_filename, out_filename).should be_true
98
+ WebP.encode(in_filename, out_filename).should be_true
99
99
  end
100
100
  end
101
101
  factories[:webp].each do |image|
102
102
  it "raise EncoderError on #{image}.webp image" do
103
103
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.webp"))
104
104
  out_filename = File.expand_path(File.join(@out_dir, "#{image}invalid.webp.png"))
105
- expect { WebpFfi.encode(in_filename, out_filename) }.to raise_error WebpFfi::EncoderError
105
+ expect { WebP.encode(in_filename, out_filename) }.to raise_error WebP::EncoderError
106
106
  end
107
107
  end
108
108
  end
@@ -112,7 +112,7 @@ describe WebpFfi do
112
112
  it "#{image}.png image" do
113
113
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.png"))
114
114
  out_filename = File.expand_path(File.join(@out_dir, "#{image}.50png.webp"))
115
- WebpFfi.encode(in_filename, out_filename, quality: 50)
115
+ WebP.encode(in_filename, out_filename, quality: 50)
116
116
  end
117
117
  end
118
118
  end
@@ -122,7 +122,7 @@ describe WebpFfi do
122
122
  it "#{image}.png image" do
123
123
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.png"))
124
124
  out_filename = File.expand_path(File.join(@out_dir, "#{image}.50png.webp"))
125
- expect { WebpFfi.encode(in_filename, out_filename, crop_w: 30000) }.to raise_error WebpFfi::EncoderError
125
+ expect { WebP.encode(in_filename, out_filename, crop_w: 30000) }.to raise_error WebP::EncoderError
126
126
  end
127
127
  end
128
128
  end
@@ -132,7 +132,7 @@ describe WebpFfi do
132
132
  it "#{image}.webp image" do
133
133
  in_filename = File.expand_path(File.join(File.dirname(__FILE__), "factories/#{image}.webp"))
134
134
  out_filename = File.expand_path(File.join(@out_dir, "#{image}.webp.png"))
135
- WebpFfi.decode(in_filename, out_filename).should be_true
135
+ WebP.decode(in_filename, out_filename).should be_true
136
136
  end
137
137
  end
138
138
  end
data/webp-ffi.gemspec CHANGED
@@ -1,11 +1,11 @@
1
1
  # coding: utf-8
2
2
  lib = File.expand_path('../lib', __FILE__)
3
3
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
- require 'webp_ffi/version'
4
+ require 'webp/version'
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "webp-ffi"
8
- spec.version = WebpFfi::VERSION
8
+ spec.version = WebP::VERSION
9
9
  spec.authors = ["Alexey Vasyliev"]
10
10
  spec.email = ["leopard.not.a@gmail.com"]
11
11
  spec.description = %q{Ruby wrapper for libwebp}
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: webp-ffi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -113,13 +113,13 @@ files:
113
113
  - ext/webp_ffi/webp_ffi.c
114
114
  - ext/webp_ffi/webp_ffi.h
115
115
  - lib/webp-ffi.rb
116
+ - lib/webp/c.rb
117
+ - lib/webp/error.rb
118
+ - lib/webp/libc.rb
119
+ - lib/webp/options.rb
120
+ - lib/webp/version.rb
121
+ - lib/webp/webp.rb
116
122
  - lib/webp_ffi.rb
117
- - lib/webp_ffi/c.rb
118
- - lib/webp_ffi/error.rb
119
- - lib/webp_ffi/libc.rb
120
- - lib/webp_ffi/options.rb
121
- - lib/webp_ffi/version.rb
122
- - lib/webp_ffi/webp_ffi.rb
123
123
  - spec/factories/1.png
124
124
  - spec/factories/1.webp
125
125
  - spec/factories/2.png
@@ -153,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
153
  version: '0'
154
154
  segments:
155
155
  - 0
156
- hash: 2298624109850622941
156
+ hash: 2929211234645012291
157
157
  required_rubygems_version: !ruby/object:Gem::Requirement
158
158
  none: false
159
159
  requirements:
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  version: '0'
163
163
  segments:
164
164
  - 0
165
- hash: 2298624109850622941
165
+ hash: 2929211234645012291
166
166
  requirements: []
167
167
  rubyforge_project:
168
168
  rubygems_version: 1.8.25
@@ -1,3 +0,0 @@
1
- module WebpFfi
2
- VERSION = "0.1.2"
3
- end