pura-webp 0.2.0 → 0.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 02daf4b19a84439a95985701909b9a269cfa02c74932440abe0cb2e369c66669
4
- data.tar.gz: addad87ed565e4f4ffb906f03a50894737829dabf598180b76240c586b847266
3
+ metadata.gz: 2538adf66ffb7ef7b402415e4fa5d652bd9cea83047161bedf9238e360f8410c
4
+ data.tar.gz: 8811664f3f74080d52de15245dd4f53d42e02103a4b6d182aeaf82fae06573aa
5
5
  SHA512:
6
- metadata.gz: 3ec5fd7e14f33bea4582eeee83462b2ae6eaf880f45822a073df095ed0720dff8716740a94570a17a5c903b5cce5eac0cc378b602626ea2aea9e27a1fae003bf
7
- data.tar.gz: 3e4d23bcd37b0bcfd1c5f2728affb2d8ab1425cbeeb658f1a92a0a26a428377d58a538007d26ee5193686b42ba1abf4c5f78cbaffa49aa5190671ffc34598ebb
6
+ metadata.gz: 59521cfe02f81816a6920d8db080f68cdc610571ac9281046fd8aecb858646e781fc017d9a208c8ce859d4a853fedd4db86f72e73a61930d25388d6cfd577a11
7
+ data.tar.gz: 2568ea7c17827bac6dad8dabf95e93d11505c9bd78be2ea43fe1b4657860ae15a33561b74123481aa58b605f9adc12cb576b2b269178124322c1e9c853edb3ea
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pura-webp
2
2
 
3
- A pure Ruby WebP decoder and encoder with zero C extension dependencies.
3
+ A pure Ruby WebP decoder and encoder without additional image-processing libraries.
4
4
 
5
5
  Part of the **pura-*** series — pure Ruby image codec gems.
6
6
 
@@ -8,7 +8,7 @@ Part of the **pura-*** series — pure Ruby image codec gems.
8
8
 
9
9
  - VP8 lossy WebP decoding
10
10
  - VP8L lossless WebP encoding
11
- - No native extensions, no FFI, no external dependencies
11
+ - No image-specific native extension or FFI dependency
12
12
  - CLI tool included
13
13
 
14
14
  ## Installation
@@ -39,6 +39,8 @@ Pura::Webp.encode(thumb, "thumb.webp")
39
39
 
40
40
  ## Benchmark
41
41
 
42
+ These historical measurements include ffmpeg process startup. They do not compare against an in-process C codec or establish Rails pipeline throughput.
43
+
42
44
  Decode performance on a 400×400 WebP image, Ruby 4.0.2 + YJIT:
43
45
 
44
46
  | Operation | pura-webp | ffmpeg (C + SIMD) | vs ffmpeg |
@@ -48,8 +50,6 @@ Decode performance on a 400×400 WebP image, Ruby 4.0.2 + YJIT:
48
50
  ## Why pure Ruby?
49
51
 
50
52
  - **`gem install` and go** — no `brew install webp`, no `apt install libwebp-dev`
51
- - **Works everywhere Ruby works** — CRuby, ruby.wasm, mruby, JRuby, TruffleRuby
52
- - **Edge/Wasm ready** — browsers (ruby.wasm), sandboxed environments
53
53
  - **No system library needed** — unlike every other Ruby WebP solution
54
54
 
55
55
  ## Current Limitations
@@ -71,6 +71,12 @@ Decode performance on a 400×400 WebP image, Ruby 4.0.2 + YJIT:
71
71
  | **pura-webp** | **WebP** | ✅ |
72
72
  | [pura-image](https://github.com/komagata/pura-image) | All formats | ✅ |
73
73
 
74
+ ## Pixel model and limitations
75
+
76
+ Images contain 8-bit RGB pixels. The encoder produces VP8L, which this decoder cannot read back yet. Decoded pixels are RGB and do not retain alpha. Multi-partition VP8 frames are also unsupported.
77
+
78
+ `crop(x, y, width, height)` requires integer coordinates, positive dimensions, and a region entirely inside the image; invalid regions raise `ArgumentError`.
79
+
74
80
  ## License
75
81
 
76
82
  MIT — see [LICENSE](LICENSE).
@@ -81,6 +81,11 @@ module Pura
81
81
  end
82
82
 
83
83
  def crop(x, y, w, h)
84
+ unless [x, y, w, h].all?(Integer) &&
85
+ x >= 0 && y >= 0 && w.positive? && h.positive? && x + w <= @width && y + h <= @height
86
+ raise ArgumentError, "crop must be a positive integer region within the image"
87
+ end
88
+
84
89
  out = String.new(encoding: Encoding::BINARY, capacity: w * h * 3)
85
90
  h.times do |row|
86
91
  src_offset = (((y + row) * @width) + x) * 3
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pura
4
4
  module Webp
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pura-webp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - komagata