oximg 0.10.1-x86_64-linux-gnu → 0.12.0-x86_64-linux-gnu
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 +4 -0
- data/exe/oximg +0 -0
- data/lib/oximg/version.rb +7 -5
- data/lib/oximg.rb +34 -11
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fa259ac9d876ff51995d84c5826f4fbe4712e144ee6beeea9edf70f87e5009a2
|
|
4
|
+
data.tar.gz: 9f7dbf591353da5f44da2a6268644621e1ac620318cc185ea87ff292d83a27d5
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 25e1e1c1bced631f32c7d263e7872e7a8c7922404be160f00ad5c4d6fc2a559b7fc61cdbc91863ee9c86d4afd3e7abc2cc774c8bbd23db33a03d0ef3b18b0812
|
|
7
|
+
data.tar.gz: 89a63ed7e8177cb911bbc1600a1707831038705993e39c9751efaa9441200099e3c5773e368b5228a6e90847b7dcaf8623a5138f1810db2f9201d1d5f2938864
|
data/README.md
CHANGED
|
@@ -22,6 +22,10 @@ Oximg.probe("in.jpg")
|
|
|
22
22
|
#=> {content_type: "image/jpeg", format: :jpeg, width: 4000, height: 3000}
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
+
A GIF source is read and probed like the others (`format: :gif`), but
|
|
26
|
+
nothing encodes GIF: it leaves as the destination's format, WebP when
|
|
27
|
+
the name does not say, and `:gif` is not a `format:` you can ask for.
|
|
28
|
+
|
|
25
29
|
## Resizing
|
|
26
30
|
|
|
27
31
|
```ruby
|
data/exe/oximg
CHANGED
|
Binary file
|
data/lib/oximg/version.rb
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module Oximg
|
|
4
|
-
# The gem version
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
|
|
4
|
+
# The gem version is the version of the oximg it bundles — the same
|
|
5
|
+
# convention the npm package uses. A gem-only fix therefore waits for
|
|
6
|
+
# the next oximg release rather than shipping under a version that
|
|
7
|
+
# names a binary it does not carry. `Oximg.version` reports what the
|
|
8
|
+
# resolved executable actually is, which can differ when it comes
|
|
9
|
+
# from PATH.
|
|
10
|
+
VERSION = "0.12.0"
|
|
9
11
|
end
|
data/lib/oximg.rb
CHANGED
|
@@ -45,10 +45,25 @@ module Oximg
|
|
|
45
45
|
"image/jpeg" => :jpeg,
|
|
46
46
|
"image/png" => :png,
|
|
47
47
|
"image/webp" => :webp,
|
|
48
|
-
"image/avif" => :avif
|
|
48
|
+
"image/avif" => :avif,
|
|
49
|
+
"image/gif" => :gif
|
|
49
50
|
}.freeze
|
|
50
51
|
|
|
51
|
-
|
|
52
|
+
# The line `oximg probe` prints (src/cli.rs):
|
|
53
|
+
#
|
|
54
|
+
# in.gif: image/gif 120x90 (10800 stored pixels), 3 frames, 1500ms, looping forever
|
|
55
|
+
#
|
|
56
|
+
# The three fields the gem reports are pinned exactly. Everything after
|
|
57
|
+
# the comma — the animation summary, printed for an animated source
|
|
58
|
+
# only — is information the gem does not expose, and is deliberately
|
|
59
|
+
# left unparsed rather than matched: a pattern that stopped at
|
|
60
|
+
# `pixels)` is what broke probe when the CLI added that summary, and a
|
|
61
|
+
# pattern that spelled the summary out would break again on the next
|
|
62
|
+
# field. What is refused is output that is not exactly that one line:
|
|
63
|
+
# a field missing, a continuation without the comma, or anything
|
|
64
|
+
# printed before or after it. stderr is captured separately, so a
|
|
65
|
+
# warning never lands here.
|
|
66
|
+
PROBE_LINE = /\A[^\n]*: (\S+) (\d+)x(\d+) \(\d+ stored pixels\)(?:,[^\n]*)?\n?\z/
|
|
52
67
|
|
|
53
68
|
class << self
|
|
54
69
|
# Absolute path to the executable in use; raises
|
|
@@ -96,15 +111,7 @@ module Oximg
|
|
|
96
111
|
# dimensions are the stored ones (an EXIF rotation is not applied).
|
|
97
112
|
def probe(source)
|
|
98
113
|
out, = Binary.run("probe", expand(source, "source"))
|
|
99
|
-
|
|
100
|
-
raise ProcessingError, "unparsable probe output: #{out.inspect}" unless match
|
|
101
|
-
|
|
102
|
-
{
|
|
103
|
-
content_type: match[1],
|
|
104
|
-
format: CONTENT_TYPE_FORMATS[match[1]],
|
|
105
|
-
width: Integer(match[2]),
|
|
106
|
-
height: Integer(match[3])
|
|
107
|
-
}
|
|
114
|
+
parse_probe(out)
|
|
108
115
|
end
|
|
109
116
|
|
|
110
117
|
# The argv `resize` would run, minus the executable. Public because
|
|
@@ -126,6 +133,22 @@ module Oximg
|
|
|
126
133
|
|
|
127
134
|
private
|
|
128
135
|
|
|
136
|
+
# The hash `probe` builds from the line the CLI printed. Separate
|
|
137
|
+
# from `probe` so the parser can be tested against every line the
|
|
138
|
+
# CLI can print — the still form, each loop spelling — without a
|
|
139
|
+
# binary present; private because nothing outside needs it.
|
|
140
|
+
def parse_probe(output)
|
|
141
|
+
match = output.match(PROBE_LINE)
|
|
142
|
+
raise ProcessingError, "unparsable probe output: #{output.inspect}" unless match
|
|
143
|
+
|
|
144
|
+
{
|
|
145
|
+
content_type: match[1],
|
|
146
|
+
format: CONTENT_TYPE_FORMATS[match[1]],
|
|
147
|
+
width: Integer(match[2]),
|
|
148
|
+
height: Integer(match[3])
|
|
149
|
+
}
|
|
150
|
+
end
|
|
151
|
+
|
|
129
152
|
# Absolute paths throughout: a relative name beginning with "-"
|
|
130
153
|
# would otherwise reach the CLI's argument parser as a flag, and
|
|
131
154
|
# the caller rarely controls what an uploaded file is called.
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: oximg
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.12.0
|
|
5
5
|
platform: x86_64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- oximg contributors
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
11
|
dependencies: []
|
|
12
12
|
description: 'Ruby bindings for oximg, the high-performance Rust image compression
|
|
13
13
|
and resizing engine: JPEG, PNG, WebP and AVIF, resized in linear light. Platform
|
|
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
46
46
|
- !ruby/object:Gem::Version
|
|
47
47
|
version: '0'
|
|
48
48
|
requirements: []
|
|
49
|
-
rubygems_version: 3.6.
|
|
49
|
+
rubygems_version: 3.6.9
|
|
50
50
|
specification_version: 4
|
|
51
51
|
summary: Image compression and resizing for Ruby, without libvips or ImageMagick
|
|
52
52
|
test_files: []
|