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 +4 -4
- data/README.md +10 -4
- data/lib/pura/webp/image.rb +5 -0
- data/lib/pura/webp/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2538adf66ffb7ef7b402415e4fa5d652bd9cea83047161bedf9238e360f8410c
|
|
4
|
+
data.tar.gz: 8811664f3f74080d52de15245dd4f53d42e02103a4b6d182aeaf82fae06573aa
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
|
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
|
|
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).
|
data/lib/pura/webp/image.rb
CHANGED
|
@@ -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
|
data/lib/pura/webp/version.rb
CHANGED