himg 0.0.10 → 0.0.11
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/Appraisals +20 -0
- data/CHANGELOG.md +7 -0
- data/Cargo.lock +1 -1
- data/README.md +8 -2
- data/ext/himg/Cargo.toml +1 -1
- data/gemfiles/plain_ruby.gemfile.lock +3 -77
- data/gemfiles/rails_6.gemfile +1 -0
- data/gemfiles/rails_6.gemfile.lock +3 -47
- data/gemfiles/rails_7_0.gemfile +1 -0
- data/gemfiles/rails_7_0.gemfile.lock +3 -48
- data/gemfiles/rails_7_1.gemfile.lock +2 -46
- data/gemfiles/rails_7_2.gemfile.lock +2 -47
- data/gemfiles/rails_8.gemfile.lock +2 -46
- data/lib/himg/cli.rb +32 -6
- data/lib/himg/version.rb +1 -1
- data/logo.svg +57 -0
- data/readme_opengraph_comparison.png +0 -0
- data/website/himg-opengraph.png +0 -0
- data/website/index.html +694 -0
- metadata +6 -16
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
himg (0.0.
|
4
|
+
himg (0.0.10)
|
5
5
|
rb_sys (~> 0.9)
|
6
6
|
|
7
7
|
GEM
|
@@ -78,10 +78,6 @@ GEM
|
|
78
78
|
minitest (>= 5.1)
|
79
79
|
securerandom (>= 0.3)
|
80
80
|
tzinfo (~> 2.0, >= 2.0.5)
|
81
|
-
appraisal (2.5.0)
|
82
|
-
bundler
|
83
|
-
rake
|
84
|
-
thor (>= 0.14.0)
|
85
81
|
ast (2.4.3)
|
86
82
|
base64 (0.2.0)
|
87
83
|
benchmark (0.4.0)
|
@@ -91,7 +87,6 @@ GEM
|
|
91
87
|
concurrent-ruby (1.3.5)
|
92
88
|
connection_pool (2.5.1)
|
93
89
|
crass (1.0.6)
|
94
|
-
csv (3.3.4)
|
95
90
|
date (3.4.1)
|
96
91
|
debug (1.10.0)
|
97
92
|
irb (~> 1.10)
|
@@ -99,15 +94,6 @@ GEM
|
|
99
94
|
diff-lcs (1.6.1)
|
100
95
|
drb (2.2.1)
|
101
96
|
erubi (1.13.1)
|
102
|
-
ffi (1.17.2-aarch64-linux-gnu)
|
103
|
-
ffi (1.17.2-aarch64-linux-musl)
|
104
|
-
ffi (1.17.2-arm-linux-gnu)
|
105
|
-
ffi (1.17.2-arm-linux-musl)
|
106
|
-
ffi (1.17.2-arm64-darwin)
|
107
|
-
ffi (1.17.2-x86_64-darwin)
|
108
|
-
ffi (1.17.2-x86_64-linux-gnu)
|
109
|
-
ffi (1.17.2-x86_64-linux-musl)
|
110
|
-
fileutils (1.7.3)
|
111
97
|
globalid (1.2.1)
|
112
98
|
activesupport (>= 6.1)
|
113
99
|
i18n (1.14.7)
|
@@ -120,9 +106,6 @@ GEM
|
|
120
106
|
json (2.10.2)
|
121
107
|
language_server-protocol (3.17.0.4)
|
122
108
|
lint_roller (1.1.0)
|
123
|
-
listen (3.9.0)
|
124
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
125
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
126
109
|
logger (1.7.0)
|
127
110
|
loofah (2.24.0)
|
128
111
|
crass (~> 1.0.2)
|
@@ -135,7 +118,6 @@ GEM
|
|
135
118
|
marcel (1.0.4)
|
136
119
|
mini_mime (1.1.5)
|
137
120
|
minitest (5.25.5)
|
138
|
-
mutex_m (0.3.0)
|
139
121
|
net-imap (0.5.6)
|
140
122
|
date
|
141
123
|
net-protocol
|
@@ -216,13 +198,8 @@ GEM
|
|
216
198
|
rake-compiler (1.3.0)
|
217
199
|
rake
|
218
200
|
rake-compiler-dock (1.9.1)
|
219
|
-
rb-fsevent (0.11.2)
|
220
|
-
rb-inotify (0.11.1)
|
221
|
-
ffi (~> 1.0)
|
222
201
|
rb_sys (0.9.111)
|
223
202
|
rake-compiler-dock (= 1.9.1)
|
224
|
-
rbs (3.9.2)
|
225
|
-
logger
|
226
203
|
rdoc (6.13.1)
|
227
204
|
psych (>= 4.0.0)
|
228
205
|
regexp_parser (2.10.0)
|
@@ -265,27 +242,7 @@ GEM
|
|
265
242
|
prism (~> 1.4)
|
266
243
|
ruby-progressbar (1.13.0)
|
267
244
|
securerandom (0.4.1)
|
268
|
-
steep (1.10.0)
|
269
|
-
activesupport (>= 5.1)
|
270
|
-
concurrent-ruby (>= 1.1.10)
|
271
|
-
csv (>= 3.0.9)
|
272
|
-
fileutils (>= 1.1.0)
|
273
|
-
json (>= 2.1.0)
|
274
|
-
language_server-protocol (>= 3.17.0.4, < 4.0)
|
275
|
-
listen (~> 3.0)
|
276
|
-
logger (>= 1.3.0)
|
277
|
-
mutex_m (>= 0.3.0)
|
278
|
-
parser (>= 3.1)
|
279
|
-
rainbow (>= 2.2.2, < 4.0)
|
280
|
-
rbs (~> 3.9)
|
281
|
-
securerandom (>= 0.1)
|
282
|
-
strscan (>= 1.0.0)
|
283
|
-
terminal-table (>= 2, < 5)
|
284
|
-
uri (>= 0.12.0)
|
285
245
|
stringio (3.1.7)
|
286
|
-
strscan (3.1.3)
|
287
|
-
terminal-table (4.0.0)
|
288
|
-
unicode-display_width (>= 1.1.1, < 4)
|
289
246
|
thor (1.3.2)
|
290
247
|
timeout (0.4.3)
|
291
248
|
tzinfo (2.0.6)
|
@@ -293,7 +250,6 @@ GEM
|
|
293
250
|
unicode-display_width (3.1.4)
|
294
251
|
unicode-emoji (~> 4.0, >= 4.0.4)
|
295
252
|
unicode-emoji (4.0.4)
|
296
|
-
uri (1.0.3)
|
297
253
|
useragent (0.16.11)
|
298
254
|
websocket-driver (0.7.7)
|
299
255
|
base64
|
@@ -312,7 +268,6 @@ PLATFORMS
|
|
312
268
|
x86_64-linux-musl
|
313
269
|
|
314
270
|
DEPENDENCIES
|
315
|
-
appraisal
|
316
271
|
bump
|
317
272
|
debug
|
318
273
|
himg!
|
@@ -323,7 +278,7 @@ DEPENDENCIES
|
|
323
278
|
rspec
|
324
279
|
rspec-rails (~> 7.0)
|
325
280
|
rubocop
|
326
|
-
|
281
|
+
thor
|
327
282
|
|
328
283
|
BUNDLED WITH
|
329
284
|
2.6.7
|
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ..
|
3
3
|
specs:
|
4
|
-
himg (0.0.
|
4
|
+
himg (0.0.10)
|
5
5
|
rb_sys (~> 0.9)
|
6
6
|
|
7
7
|
GEM
|
@@ -78,10 +78,6 @@ GEM
|
|
78
78
|
securerandom (>= 0.3)
|
79
79
|
tzinfo (~> 2.0, >= 2.0.5)
|
80
80
|
uri (>= 0.13.1)
|
81
|
-
appraisal (2.5.0)
|
82
|
-
bundler
|
83
|
-
rake
|
84
|
-
thor (>= 0.14.0)
|
85
81
|
ast (2.4.3)
|
86
82
|
base64 (0.2.0)
|
87
83
|
benchmark (0.4.0)
|
@@ -91,7 +87,6 @@ GEM
|
|
91
87
|
concurrent-ruby (1.3.5)
|
92
88
|
connection_pool (2.5.1)
|
93
89
|
crass (1.0.6)
|
94
|
-
csv (3.3.4)
|
95
90
|
date (3.4.1)
|
96
91
|
debug (1.10.0)
|
97
92
|
irb (~> 1.10)
|
@@ -99,15 +94,6 @@ GEM
|
|
99
94
|
diff-lcs (1.6.1)
|
100
95
|
drb (2.2.1)
|
101
96
|
erubi (1.13.1)
|
102
|
-
ffi (1.17.2-aarch64-linux-gnu)
|
103
|
-
ffi (1.17.2-aarch64-linux-musl)
|
104
|
-
ffi (1.17.2-arm-linux-gnu)
|
105
|
-
ffi (1.17.2-arm-linux-musl)
|
106
|
-
ffi (1.17.2-arm64-darwin)
|
107
|
-
ffi (1.17.2-x86_64-darwin)
|
108
|
-
ffi (1.17.2-x86_64-linux-gnu)
|
109
|
-
ffi (1.17.2-x86_64-linux-musl)
|
110
|
-
fileutils (1.7.3)
|
111
97
|
globalid (1.2.1)
|
112
98
|
activesupport (>= 6.1)
|
113
99
|
i18n (1.14.7)
|
@@ -120,9 +106,6 @@ GEM
|
|
120
106
|
json (2.10.2)
|
121
107
|
language_server-protocol (3.17.0.4)
|
122
108
|
lint_roller (1.1.0)
|
123
|
-
listen (3.9.0)
|
124
|
-
rb-fsevent (~> 0.10, >= 0.10.3)
|
125
|
-
rb-inotify (~> 0.9, >= 0.9.10)
|
126
109
|
logger (1.7.0)
|
127
110
|
loofah (2.24.0)
|
128
111
|
crass (~> 1.0.2)
|
@@ -135,7 +118,6 @@ GEM
|
|
135
118
|
marcel (1.0.4)
|
136
119
|
mini_mime (1.1.5)
|
137
120
|
minitest (5.25.5)
|
138
|
-
mutex_m (0.3.0)
|
139
121
|
net-imap (0.5.6)
|
140
122
|
date
|
141
123
|
net-protocol
|
@@ -216,13 +198,8 @@ GEM
|
|
216
198
|
rake-compiler (1.3.0)
|
217
199
|
rake
|
218
200
|
rake-compiler-dock (1.9.1)
|
219
|
-
rb-fsevent (0.11.2)
|
220
|
-
rb-inotify (0.11.1)
|
221
|
-
ffi (~> 1.0)
|
222
201
|
rb_sys (0.9.111)
|
223
202
|
rake-compiler-dock (= 1.9.1)
|
224
|
-
rbs (3.9.2)
|
225
|
-
logger
|
226
203
|
rdoc (6.13.1)
|
227
204
|
psych (>= 4.0.0)
|
228
205
|
regexp_parser (2.10.0)
|
@@ -265,27 +242,7 @@ GEM
|
|
265
242
|
prism (~> 1.4)
|
266
243
|
ruby-progressbar (1.13.0)
|
267
244
|
securerandom (0.4.1)
|
268
|
-
steep (1.10.0)
|
269
|
-
activesupport (>= 5.1)
|
270
|
-
concurrent-ruby (>= 1.1.10)
|
271
|
-
csv (>= 3.0.9)
|
272
|
-
fileutils (>= 1.1.0)
|
273
|
-
json (>= 2.1.0)
|
274
|
-
language_server-protocol (>= 3.17.0.4, < 4.0)
|
275
|
-
listen (~> 3.0)
|
276
|
-
logger (>= 1.3.0)
|
277
|
-
mutex_m (>= 0.3.0)
|
278
|
-
parser (>= 3.1)
|
279
|
-
rainbow (>= 2.2.2, < 4.0)
|
280
|
-
rbs (~> 3.9)
|
281
|
-
securerandom (>= 0.1)
|
282
|
-
strscan (>= 1.0.0)
|
283
|
-
terminal-table (>= 2, < 5)
|
284
|
-
uri (>= 0.12.0)
|
285
245
|
stringio (3.1.7)
|
286
|
-
strscan (3.1.3)
|
287
|
-
terminal-table (4.0.0)
|
288
|
-
unicode-display_width (>= 1.1.1, < 4)
|
289
246
|
thor (1.3.2)
|
290
247
|
timeout (0.4.3)
|
291
248
|
tzinfo (2.0.6)
|
@@ -312,7 +269,6 @@ PLATFORMS
|
|
312
269
|
x86_64-linux-musl
|
313
270
|
|
314
271
|
DEPENDENCIES
|
315
|
-
appraisal
|
316
272
|
bump
|
317
273
|
debug
|
318
274
|
himg!
|
@@ -323,7 +279,7 @@ DEPENDENCIES
|
|
323
279
|
rspec
|
324
280
|
rspec-rails (~> 7.0)
|
325
281
|
rubocop
|
326
|
-
|
282
|
+
thor
|
327
283
|
|
328
284
|
BUNDLED WITH
|
329
285
|
2.6.7
|
data/lib/himg/cli.rb
CHANGED
@@ -1,9 +1,22 @@
|
|
1
1
|
require "thor"
|
2
2
|
require "himg"
|
3
3
|
require "open-uri"
|
4
|
+
require "uri"
|
4
5
|
|
5
6
|
module Himg
|
6
7
|
class CLI < Thor
|
8
|
+
default_command :usage
|
9
|
+
|
10
|
+
desc "usage", "Show usage for screenshot command", hide: true
|
11
|
+
def usage
|
12
|
+
puts "himg v#{VERSION}"
|
13
|
+
puts
|
14
|
+
puts "Converts HTML to PNG images using a lightweight, minimal renderer."
|
15
|
+
puts "Ideal for generating OpenGraph images from purpose-built HTML."
|
16
|
+
puts
|
17
|
+
CLI.command_help(Thor::Base.shell.new, 'screenshot')
|
18
|
+
end
|
19
|
+
|
7
20
|
desc "screenshot SOURCE_HTML DESTINATION_PNG [OPTIONS]", "Render HTML to a png screenshot"
|
8
21
|
|
9
22
|
option :width, type: :numeric, desc: "Sets the width of the rendered content.", default: 720
|
@@ -13,7 +26,7 @@ module Himg
|
|
13
26
|
option :disable_fetch, type: :boolean, desc: "Skip fetching file/http resources (stylesheets, images, fonts, etc)", default: false
|
14
27
|
option :fetch_timeout, type: :numeric, desc: "Timeout in seconds for fetching resources", default: 10
|
15
28
|
option :gpu, type: :boolean, desc: "Use GPU renderer instead of CPU renderer", default: false
|
16
|
-
option :http_headers, desc: "HTTP
|
29
|
+
option :http_headers, type: :hash, desc: "HTTP headers sent when fetching the SOURCE_HTML (e.g. --http-headers \"Authorization: Bearer token\" \"Content-Type: application/json\")"
|
17
30
|
option :base_url, desc: "Base URL used to resolve relative URLs"
|
18
31
|
|
19
32
|
long_desc <<-LONGDESC
|
@@ -27,8 +40,13 @@ module Himg
|
|
27
40
|
Additionally it does not use a JavaScript engine, so will screenshot the page as-is and would not work for all webpages.
|
28
41
|
LONGDESC
|
29
42
|
def screenshot(url, destination)
|
43
|
+
options[:http_headers]&.transform_values!(&:strip)
|
44
|
+
|
30
45
|
Document.new(url, options).load do |content|
|
31
|
-
|
46
|
+
render_options = options.transform_keys(&:to_sym)
|
47
|
+
render_options[:base_url] ||= base_directory_url(url) if Document.http_url?(url)
|
48
|
+
|
49
|
+
png = Himg.render(content, **render_options)
|
32
50
|
|
33
51
|
File.open(destination, "wb") { |f| f.write(png) }
|
34
52
|
end
|
@@ -36,6 +54,10 @@ module Himg
|
|
36
54
|
|
37
55
|
private
|
38
56
|
|
57
|
+
def base_directory_url(url)
|
58
|
+
URI.join(url, ".").to_s
|
59
|
+
end
|
60
|
+
|
39
61
|
def self.exit_on_failure?
|
40
62
|
true
|
41
63
|
end
|
@@ -44,15 +66,19 @@ module Himg
|
|
44
66
|
def initialize(source, options)
|
45
67
|
@source = source
|
46
68
|
@options = options
|
69
|
+
@http_headers = options[:http_headers]
|
47
70
|
end
|
48
71
|
|
49
|
-
def http_url?
|
50
|
-
|
72
|
+
def self.http_url?(url)
|
73
|
+
url =~ %r{\Ahttps?\://}
|
51
74
|
end
|
52
75
|
|
53
76
|
def load(&block)
|
54
|
-
if http_url?
|
55
|
-
|
77
|
+
if self.class.http_url?(@source)
|
78
|
+
args = [@source]
|
79
|
+
args << @http_headers if @http_headers
|
80
|
+
|
81
|
+
URI.open(*args) do |input|
|
56
82
|
yield(input.binmode.read)
|
57
83
|
end
|
58
84
|
else
|
data/lib/himg/version.rb
CHANGED
data/logo.svg
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg width="220" height="80" viewBox="0 0 220 80" version="1.1" id="svg32" xmlns="http://www.w3.org/2000/svg" xmlns:svg="http://www.w3.org/2000/svg">
|
3
|
+
<defs id="defs14">
|
4
|
+
<linearGradient id="waveGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
5
|
+
<stop offset="0%" stop-color="#FF006E" id="stop2" />
|
6
|
+
<stop offset="50%" stop-color="#8338EC" id="stop4" />
|
7
|
+
<stop offset="100%" stop-color="#3A86FF" id="stop6" />
|
8
|
+
</linearGradient>
|
9
|
+
<linearGradient id="borderGradient" x1="0%" y1="0%" x2="100%" y2="0%">
|
10
|
+
<stop offset="0%" stop-color="#8338EC" id="stop9" />
|
11
|
+
<stop offset="100%" stop-color="#3A86FF" id="stop11" />
|
12
|
+
</linearGradient>
|
13
|
+
</defs>
|
14
|
+
|
15
|
+
<!-- H letter -->
|
16
|
+
<g aria-label="H" id="text16" style="font-weight:800;font-size:72px;font-family:'Noto Sans';fill:#ff006e">
|
17
|
+
<path
|
18
|
+
d="M 48.6,60 H 37.728 V 37.824 H 17.352 V 60 H 6.48 V 8.592 h 10.872 v 20.16 H 37.728 V 8.592 H 48.6 Z"
|
19
|
+
id="path36" />
|
20
|
+
</g>
|
21
|
+
|
22
|
+
<!-- Flowing wave connector centered on H -->
|
23
|
+
<g transform="translate(60,5)" id="g22">
|
24
|
+
<svg width="120" height="60" viewBox="0 0 120 60" version="1.1" id="svg20">
|
25
|
+
<path d="m 0,30 q 30,-20 60,0 30,20 60,0" stroke="url(#waveGradient)" stroke-width="4" fill="none" id="path18">
|
26
|
+
<animate
|
27
|
+
attributeName="d"
|
28
|
+
values="M 0 30 Q 30 10, 60 30 T 120 30; M 0 30 Q 30 50, 60 30 T 120 30; M 0 30 Q 30 10, 60 30 T 120 30"
|
29
|
+
dur="3s"
|
30
|
+
repeatCount="indefinite" />
|
31
|
+
</path>
|
32
|
+
</svg>
|
33
|
+
</g>
|
34
|
+
<g transform="translate(160,35)" id="g30">
|
35
|
+
|
36
|
+
<!-- Background for gradient border -->
|
37
|
+
<path id="rect24" style="fill:url(#borderGradient)"
|
38
|
+
d="m -10,-20 h 40 c 11.08,0 20,8.92 20,20 0,11.08 -8.92,20 -20,20 h -40 c -11.08,0 -20,-8.92 -20,-20 0,-11.08 8.92,-20 20,-20 z" />
|
39
|
+
|
40
|
+
<!-- White fill on top with 2px border -->
|
41
|
+
<path id="rect26" style="fill:#ffffff"
|
42
|
+
d="m -10,-18 h 40 c 9.972,0 18,8.028 18,18 0,9.972 -8.028,18 -18,18 h -40 c -9.972,0 -18,-8.028 -18,-18 0,-9.972 8.028,-18 18,-18 z" />
|
43
|
+
|
44
|
+
<!-- "img" text -->
|
45
|
+
<g aria-label="img" id="text28" style="font-weight:700;font-size:24px;font-family:'Noto Sans';text-anchor:middle;fill:#333333">
|
46
|
+
<path
|
47
|
+
d="m -9.3680009,-10.24 q 0.792,0 1.368,0.384 0.576,0.36 0.576,1.368 0,0.984 -0.576,1.368 -0.576,0.384 -1.368,0.384 -0.8160001,0 -1.3920001,-0.384 -0.552,-0.384 -0.552,-1.368 0,-1.008 0.552,-1.368 0.576,-0.384 1.3920001,-0.384 z m 1.776,5.136 V 8 H -11.168001 V -5.104 Z"
|
48
|
+
id="path41" />
|
49
|
+
<path
|
50
|
+
d="m 11.536006,-5.344 q 2.232,0 3.36,1.152 1.152,1.128 1.152,3.648 V 8 h -3.576 V 0.344 q 0,-2.832 -1.968,-2.832 -1.4159996,0 -2.0159996,1.008 -0.6,1.008 -0.6,2.904 V 8 h -3.576 V 0.344 q 0,-2.832 -1.968,-2.832 -1.48799999,0 -2.06399999,1.128 -0.552,1.104 -0.552,3.192 V 8 H -3.8479936 V -5.104 h 2.736 l 0.48000001,1.68 h 0.192 q 0.6,-1.008 1.63199999,-1.464 1.056,-0.456 2.184,-0.456 1.44,0 2.448,0.48 1.008,0.456 1.536,1.44 h 0.312 q 0.6,-1.008 1.656,-1.464 1.0799996,-0.456 2.2079996,-0.456 z"
|
51
|
+
id="path43" />
|
52
|
+
<path
|
53
|
+
d="m 23.968015,-5.344 q 2.424,0 3.792,1.92 h 0.096 l 0.288,-1.68 h 3.024 V 8.024 q 0,2.808 -1.656,4.272 -1.656,1.464 -4.896,1.464 -1.392,0 -2.592,-0.168 -1.176,-0.168 -2.304,-0.6 v -2.856 q 2.424,1.008 5.112,1.008 2.76,0 2.76,-2.976 V 7.904 q 0,-0.408 0.024,-0.84 0.048,-0.432 0.072,-0.768 h -0.096 q -0.672,1.032 -1.608,1.488 -0.936,0.456 -2.112,0.456 -2.328,0 -3.648,-1.776 -1.296,-1.8 -1.296,-4.992 0,-3.216 1.344,-5.016 1.344,-1.8 3.696,-1.8 z m 1.128,2.904 q -2.52,0 -2.52,3.96 0,3.912 2.568,3.912 1.368,0 2.016,-0.768 0.672,-0.792 0.672,-2.736 V 1.496 q 0,-2.112 -0.648,-3.024 -0.648,-0.912 -2.088,-0.912 z"
|
54
|
+
id="path45" />
|
55
|
+
</g>
|
56
|
+
</g>
|
57
|
+
</svg>
|
Binary file
|
Binary file
|