pura-bmp 0.1.0 → 0.1.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: c04675c1f6dbc0d7a847e8bfdea1b0e3bf8775cb7f3dd9bd716221bd5c4d32fd
4
- data.tar.gz: 7aa89ef86fdebafc1eaf57d7970476a00933484ef80106a82a724c80a8252baf
3
+ metadata.gz: 4142bd041e92c013c3d1f4724a645a4bb01ca29edac500c6546f76511100cdf6
4
+ data.tar.gz: f3a3acac9b91640281ed4ae7b90499d7a1284f3d5db473ad75c8239cb3df2324
5
5
  SHA512:
6
- metadata.gz: 253f58ee2de6e9548ead611ee4ff28ef208bee445a771432ef2f87f7e582199a50aff016c420b1f6de975a5168401681a339a3c061ecf3f624bffe7ce4a288a5
7
- data.tar.gz: 63627ded0a9f7cfb98a89c0a0694d4b22563ef2741069e42841bc3d791214657e6893d7ea8f51d5f45eaccdfc79739bd1bcd65bf14c76809725cb242894f352b
6
+ metadata.gz: c1de9ce4f996d9149d9cc9ec5b1c1093f92cd92eaf6f4d4903a60f18379970c30aa2a8d3af7ab2a89c54087adc4eec6b796449a5b7a4cb81ae26b13d795be849
7
+ data.tar.gz: 398e6830192effbf7d9bfc8a7eb711a01fd55966b3032e08fc46ced90348c23c3a4d8623d25327a0bd57f981d85250a023f40b30915f8f76a4f60a1e82072a20
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # pura-bmp
2
2
 
3
- A pure Ruby BMP decoder/encoder with zero C extension dependencies.
3
+ A pure Ruby BMP decoder/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
  - BMP decoding and encoding (24-bit RGB)
10
10
  - Image resizing (bilinear / nearest-neighbor / fit / fill)
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
@@ -46,6 +46,8 @@ pura-bmp resize input.bmp --width 200 --height 200 --out thumb.bmp
46
46
 
47
47
  ## Benchmark
48
48
 
49
+ These historical measurements include ffmpeg process startup. They do not compare against an in-process C codec or establish Rails pipeline throughput.
50
+
49
51
  400×400 image, Ruby 4.0.2 + YJIT.
50
52
 
51
53
  ### Decode
@@ -55,7 +57,6 @@ pura-bmp resize input.bmp --width 200 --height 200 --out thumb.bmp
55
57
  | **pura-bmp** | **39 ms** |
56
58
  | ffmpeg (C) | 59 ms |
57
59
 
58
- **pura-bmp is faster than ffmpeg** for BMP decoding. No other pure Ruby BMP implementation exists.
59
60
 
60
61
  ### Encode
61
62
 
@@ -67,8 +68,6 @@ pura-bmp resize input.bmp --width 200 --height 200 --out thumb.bmp
67
68
  ## Why pure Ruby?
68
69
 
69
70
  - **`gem install` and go** — no `brew install`, no `apt install`, no C compiler needed
70
- - **Faster than C** — pure Ruby BMP decode beats ffmpeg on this benchmark
71
- - **Works everywhere Ruby works** — CRuby, ruby.wasm, JRuby, TruffleRuby
72
71
  - **Part of pura-\*** — convert between JPEG, PNG, BMP, GIF, TIFF, WebP seamlessly
73
72
 
74
73
  ## Related gems
@@ -84,6 +83,12 @@ pura-bmp resize input.bmp --width 200 --height 200 --out thumb.bmp
84
83
  | [pura-webp](https://github.com/komagata/pura-webp) | WebP | ✅ Available |
85
84
  | [pura-image](https://github.com/komagata/pura-image) | All formats | ✅ Available |
86
85
 
86
+ ## Pixel model and limitations
87
+
88
+ Images contain 8-bit RGB pixels. Decoded pixels are RGB; any alpha channel is discarded. Encoding writes 24-bit RGB BMP.
89
+
90
+ `crop(x, y, width, height)` requires integer coordinates, positive dimensions, and a region entirely inside the image; invalid regions raise `ArgumentError`.
91
+
87
92
  ## License
88
93
 
89
94
  MIT
@@ -87,6 +87,11 @@ module Pura
87
87
 
88
88
  # Crop a region from the image
89
89
  def crop(x, y, w, h)
90
+ unless [x, y, w, h].all?(Integer) &&
91
+ x >= 0 && y >= 0 && w.positive? && h.positive? && x + w <= @width && y + h <= @height
92
+ raise ArgumentError, "crop must be a positive integer region within the image"
93
+ end
94
+
90
95
  out = String.new(encoding: Encoding::BINARY, capacity: w * h * 3)
91
96
  h.times do |row|
92
97
  src_offset = (((y + row) * @width) + x) * 3
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Pura
4
4
  module Bmp
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pura-bmp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - komagata