mini_magick 5.3.1 → 5.3.3
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/lib/mini_magick/shell.rb +32 -1
- data/lib/mini_magick/tool.rb +3 -2
- data/lib/mini_magick/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ce89fb8c4944594e97e5fa8bb017b17ad827f6dd06df2effd4155b83bf8a4215
|
|
4
|
+
data.tar.gz: 4a130f7c8963143f29bad7432be8d90a68892716dffd479e56edffc45655e0a4
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ed544ea77778b627fd58ff4a80665d9560ee67d2fe4d88fc391450bf53f01647f6d515c730d97ffa301619a46334134616dbb5fc1e4f0e40ff09e81355154fbe
|
|
7
|
+
data.tar.gz: 6aaf746cdb19db2f15bbbf3d55fdb839c0df1c9504f1ba8afc8a7b822329fe61c5eac7d6f07337f2735df0c00da089cf46f3e2f387789a46b1c0e41661041469
|
data/lib/mini_magick/shell.rb
CHANGED
|
@@ -31,7 +31,38 @@ module MiniMagick
|
|
|
31
31
|
env["MAGICK_TIME_LIMIT"] = timeout.to_s if timeout
|
|
32
32
|
|
|
33
33
|
stdout, stderr, status = log(command.join(" ")) do
|
|
34
|
-
Open3.capture3
|
|
34
|
+
# We would ideally use Open3.capture3, but it doesn't allow us to
|
|
35
|
+
# terminate the command after timing out. We can't rely solely on
|
|
36
|
+
# ImageMagick's own $MAGICK_TIME_LIMIT for this, because it's only
|
|
37
|
+
# checked periodically inside ImageMagick's processing loops, so it
|
|
38
|
+
# can fire too late (or not at all) depending on the operation.
|
|
39
|
+
Open3.popen3(env, *command, unsetenv_others: MiniMagick.restricted_env) do |stdin_io, stdout_io, stderr_io, wait_thread|
|
|
40
|
+
stdin_io.binmode
|
|
41
|
+
stdout_io.binmode
|
|
42
|
+
stderr_io.binmode
|
|
43
|
+
|
|
44
|
+
stdout_reader = Thread.new { stdout_io.read }
|
|
45
|
+
stderr_reader = Thread.new { stderr_io.read }
|
|
46
|
+
|
|
47
|
+
begin
|
|
48
|
+
# Matches how Open3.capture3 detects IO objects.
|
|
49
|
+
if stdin.respond_to?(:readpartial)
|
|
50
|
+
IO.copy_stream(stdin, stdin_io)
|
|
51
|
+
else
|
|
52
|
+
stdin_io.write(stdin)
|
|
53
|
+
end
|
|
54
|
+
rescue Errno::EPIPE
|
|
55
|
+
end
|
|
56
|
+
stdin_io.close
|
|
57
|
+
|
|
58
|
+
if timeout && !wait_thread.join(timeout)
|
|
59
|
+
Process.kill("TERM", wait_thread.pid) rescue nil
|
|
60
|
+
wait_thread.join
|
|
61
|
+
fail MiniMagick::TimeoutError, "`#{command.join(" ")}` has timed out"
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
[stdout_reader.value, stderr_reader.value, wait_thread.value]
|
|
65
|
+
end
|
|
35
66
|
end
|
|
36
67
|
|
|
37
68
|
[stdout, stderr, status&.exitstatus]
|
data/lib/mini_magick/tool.rb
CHANGED
|
@@ -27,7 +27,7 @@ module MiniMagick
|
|
|
27
27
|
# instance of the tool, if block is given, returns the output of the
|
|
28
28
|
# command.
|
|
29
29
|
#
|
|
30
|
-
def self.new(
|
|
30
|
+
def self.new(*args, **options)
|
|
31
31
|
instance = super
|
|
32
32
|
|
|
33
33
|
if block_given?
|
|
@@ -46,7 +46,8 @@ module MiniMagick
|
|
|
46
46
|
# @option options [Boolean] :errors Whether to raise errors on non-zero
|
|
47
47
|
# exit codes.
|
|
48
48
|
# @option options [Boolean] :warnings Whether to print warnings to stderrr.
|
|
49
|
-
# @option options [String] :stdin Content to send to standard input
|
|
49
|
+
# @option options [String, IO] :stdin Content to send to standard input
|
|
50
|
+
# stream, either a string or a readable IO object.
|
|
50
51
|
# @example
|
|
51
52
|
# MiniMagick.identify(errors: false) do |identify|
|
|
52
53
|
# identify.help # returns exit status 1, which would otherwise throw an error
|
data/lib/mini_magick/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mini_magick
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.3.
|
|
4
|
+
version: 5.3.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Corey Johnson
|
|
@@ -99,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
99
99
|
version: '0'
|
|
100
100
|
requirements:
|
|
101
101
|
- You must have ImageMagick installed
|
|
102
|
-
rubygems_version:
|
|
102
|
+
rubygems_version: 4.0.13
|
|
103
103
|
specification_version: 4
|
|
104
104
|
summary: Manipulate images with minimal use of memory via ImageMagick
|
|
105
105
|
test_files: []
|