mini_magick 5.0.0 → 5.1.0
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 +28 -11
- data/lib/mini_magick/configuration.rb +19 -0
- data/lib/mini_magick/image.rb +7 -2
- data/lib/mini_magick/shell.rb +6 -2
- data/lib/mini_magick/tool.rb +2 -1
- data/lib/mini_magick/version.rb +1 -1
- data/lib/mini_magick.rb +2 -1
- metadata +5 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ac6bfa9bd38b6ba1482ad9d52e4ce0f983a44ae6cc51d1e7cb66c1cca49209f
|
4
|
+
data.tar.gz: e3088be1a95e47dc6b0426a8bc76f3ac071e3755f301c3d06c6d46b442ae7274
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2703437721ca376faf5674d2b0a10c34f456d0146ee4a7dc3ad506d700be9fcd098301213b1c688931ae872f8507691f02b70eb4f3131df2c1a760e8f86f25d
|
7
|
+
data.tar.gz: c8d33063710a5e0898e6bd2a5aaca6533c0d2943c4a5c545ab700de5e25eb38fa0efc4e08cf9d5eec46c3ba78d315231c541f6b4fe802306da181513b957291c
|
data/README.md
CHANGED
@@ -48,7 +48,7 @@ $ bundle add mini_magick
|
|
48
48
|
|
49
49
|
## Information
|
50
50
|
|
51
|
-
* [API documentation](
|
51
|
+
* [API documentation](https://rubydoc.info/gems/mini_magick)
|
52
52
|
|
53
53
|
## Usage
|
54
54
|
|
@@ -240,11 +240,12 @@ MiniMagick.configure do |config|
|
|
240
240
|
config.tmdir = Dir.tmpdir # alternative directory for tempfiles
|
241
241
|
config.logger = Logger.new($stdout) # where to log IM commands
|
242
242
|
config.cli_prefix = nil # add prefix to all IM commands
|
243
|
+
config.cli_env = {} # environment variables to set for IM commands
|
243
244
|
end
|
244
245
|
```
|
245
246
|
|
246
247
|
For a more information, see
|
247
|
-
[Configuration](
|
248
|
+
[Configuration](https://rubydoc.info/gems/mini_magick/MiniMagick/Configuration) API documentation.
|
248
249
|
|
249
250
|
### Composite
|
250
251
|
|
@@ -455,11 +456,14 @@ end
|
|
455
456
|
### GraphicsMagick
|
456
457
|
|
457
458
|
As of MiniMagick 5+, [GraphicsMagick](http://www.graphicsmagick.org/) isn't
|
458
|
-
officially supported.
|
459
|
+
officially supported. This means its installation won't be auto-detected, and no
|
460
|
+
attempts will be made to handle differences in GraphicsMagick API or output.
|
461
|
+
|
462
|
+
However, you can still configure MiniMagick to use it:
|
459
463
|
|
460
464
|
```rb
|
461
465
|
MiniMagick.configure do |config|
|
462
|
-
config.
|
466
|
+
config.graphicsmagick = true
|
463
467
|
end
|
464
468
|
```
|
465
469
|
|
@@ -468,16 +472,27 @@ Some MiniMagick features won't be supported, such as global timeout,
|
|
468
472
|
|
469
473
|
### Limiting resources
|
470
474
|
|
471
|
-
ImageMagick supports a number of environment variables for controlling its
|
475
|
+
ImageMagick supports a number of [environment variables] for controlling its
|
472
476
|
resource limits. For example, you can enforce memory or execution time limits by
|
473
|
-
setting the following
|
477
|
+
setting the following:
|
474
478
|
|
475
|
-
|
476
|
-
|
477
|
-
|
479
|
+
```rb
|
480
|
+
MiniMagick.configure do |config|
|
481
|
+
config.cli_env = {
|
482
|
+
"MAGICK_MEMORY_LIMIT" => "128MiB",
|
483
|
+
"MAGICK_MAP_LIMIT" => "64MiB",
|
484
|
+
"MAGICK_TIME_LIMIT" => "30"
|
485
|
+
}
|
486
|
+
end
|
487
|
+
```
|
478
488
|
|
479
|
-
For
|
480
|
-
|
489
|
+
For time limit you can also use the `timeout` configuration:
|
490
|
+
|
491
|
+
```rb
|
492
|
+
MiniMagick.configure do |config|
|
493
|
+
config.timeout = 30 # 30 seconds
|
494
|
+
end
|
495
|
+
```
|
481
496
|
|
482
497
|
### Changing temporary directory
|
483
498
|
|
@@ -538,3 +553,5 @@ Unlike RMagick, MiniMagick is a much thinner wrapper around ImageMagick.
|
|
538
553
|
* To open files with MiniMagick you use `MiniMagick::Image.open` as you would
|
539
554
|
`Magick::Image.read`. To open a file and directly edit it, use
|
540
555
|
`MiniMagick::Image.new`.
|
556
|
+
|
557
|
+
[environment variables]: https://imagemagick.org/script/resources.php#environment
|
@@ -4,6 +4,13 @@ require 'logger'
|
|
4
4
|
module MiniMagick
|
5
5
|
module Configuration
|
6
6
|
|
7
|
+
##
|
8
|
+
# Uses [GraphicsMagick](http://www.graphicsmagick.org/) instead of
|
9
|
+
# ImageMagick, by prefixing commands with `gm` instead of `magick`.
|
10
|
+
#
|
11
|
+
# @return [Boolean]
|
12
|
+
attr_accessor :graphicsmagick
|
13
|
+
|
7
14
|
##
|
8
15
|
# Adds a prefix to the CLI command.
|
9
16
|
# For example, you could use `firejail` to run all commands in a sandbox.
|
@@ -15,6 +22,16 @@ module MiniMagick
|
|
15
22
|
#
|
16
23
|
attr_accessor :cli_prefix
|
17
24
|
|
25
|
+
##
|
26
|
+
# Adds environment variables to every CLI command call.
|
27
|
+
# For example, you could use it to set `LD_PRELOAD="/path/to/libsomething.so"`.
|
28
|
+
# Must be a hash of strings keyed to valid environment variable name strings.
|
29
|
+
# e.g. {'MY_ENV' => 'my value'}
|
30
|
+
#
|
31
|
+
# @return [Hash]
|
32
|
+
#
|
33
|
+
attr_accessor :cli_env
|
34
|
+
|
18
35
|
##
|
19
36
|
# If you don't want commands to take too long, you can set a timeout (in
|
20
37
|
# seconds).
|
@@ -55,6 +72,8 @@ module MiniMagick
|
|
55
72
|
base.errors = true
|
56
73
|
base.logger = Logger.new($stdout).tap { |l| l.level = Logger::INFO }
|
57
74
|
base.warnings = true
|
75
|
+
base.cli_env = {}.freeze
|
76
|
+
base.graphicsmagick = false
|
58
77
|
end
|
59
78
|
|
60
79
|
##
|
data/lib/mini_magick/image.rb
CHANGED
@@ -465,6 +465,13 @@ module MiniMagick
|
|
465
465
|
end
|
466
466
|
end
|
467
467
|
|
468
|
+
##
|
469
|
+
# Prevents ruby from calling `#to_ary` on the image when checking if it's a
|
470
|
+
# splattable data structure in certain cases.
|
471
|
+
def respond_to_missing?(name, include_all)
|
472
|
+
false
|
473
|
+
end
|
474
|
+
|
468
475
|
##
|
469
476
|
# Writes the temporary file out to either a file location (by passing in a
|
470
477
|
# String) or by passing in a Stream that you can #write(chunk) to
|
@@ -487,8 +494,6 @@ module MiniMagick
|
|
487
494
|
else
|
488
495
|
IO.copy_stream File.open(path, "rb"), output_to
|
489
496
|
end
|
490
|
-
ensure
|
491
|
-
destroy! if tempfile
|
492
497
|
end
|
493
498
|
|
494
499
|
##
|
data/lib/mini_magick/shell.rb
CHANGED
@@ -21,14 +21,18 @@ module MiniMagick
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
-
$stderr.print(stderr) if warnings
|
24
|
+
$stderr.print(stderr) if warnings
|
25
25
|
|
26
26
|
[stdout, stderr, status]
|
27
27
|
end
|
28
28
|
|
29
29
|
def execute(command, stdin: "", timeout: MiniMagick.timeout)
|
30
|
+
env = {}
|
31
|
+
env.merge!(MiniMagick.cli_env)
|
32
|
+
env["MAGICK_TIME_LIMIT"] = timeout.to_s if timeout
|
33
|
+
|
30
34
|
stdout, stderr, status = log(command.join(" ")) do
|
31
|
-
Open3.capture3(
|
35
|
+
Open3.capture3(env, *command, stdin_data: stdin)
|
32
36
|
end
|
33
37
|
|
34
38
|
[stdout, stderr, status&.exitstatus]
|
data/lib/mini_magick/tool.rb
CHANGED
@@ -122,8 +122,9 @@ module MiniMagick
|
|
122
122
|
#
|
123
123
|
def executable
|
124
124
|
exe = [name]
|
125
|
+
exe.unshift "gm" if MiniMagick.graphicsmagick
|
125
126
|
exe.unshift "magick" if MiniMagick.imagemagick7? && name != "magick"
|
126
|
-
|
127
|
+
exe.unshift *Array(MiniMagick.cli_prefix)
|
127
128
|
exe
|
128
129
|
end
|
129
130
|
|
data/lib/mini_magick/version.rb
CHANGED
data/lib/mini_magick.rb
CHANGED
@@ -17,13 +17,14 @@ module MiniMagick
|
|
17
17
|
#
|
18
18
|
# @return [Boolean]
|
19
19
|
def self.imagemagick7?
|
20
|
+
return false if graphicsmagick
|
20
21
|
return @imagemagick7 if defined?(@imagemagick7)
|
21
22
|
@imagemagick7 = !!MiniMagick::Utilities.which("magick")
|
22
23
|
end
|
23
24
|
|
24
25
|
%w[animate compare composite conjure convert display identify import mogrify montage stream].each do |tool|
|
25
|
-
name = imagemagick7? && tool == "convert" ? "magick" : tool
|
26
26
|
define_singleton_method(tool) do |**options, &block|
|
27
|
+
name = imagemagick7? && tool == "convert" ? "magick" : tool
|
27
28
|
MiniMagick::Tool.new(name, **options, &block)
|
28
29
|
end
|
29
30
|
end
|
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.
|
4
|
+
version: 5.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Johnson
|
@@ -10,10 +10,9 @@ authors:
|
|
10
10
|
- James Miller
|
11
11
|
- Thiago Fernandes Massa
|
12
12
|
- Janko Marohnić
|
13
|
-
autorequire:
|
14
13
|
bindir: bin
|
15
14
|
cert_chain: []
|
16
|
-
date:
|
15
|
+
date: 2025-01-12 00:00:00.000000000 Z
|
17
16
|
dependencies:
|
18
17
|
- !ruby/object:Gem::Dependency
|
19
18
|
name: rake
|
@@ -35,28 +34,14 @@ dependencies:
|
|
35
34
|
requirements:
|
36
35
|
- - "~>"
|
37
36
|
- !ruby/object:Gem::Version
|
38
|
-
version: 3.5
|
37
|
+
version: '3.5'
|
39
38
|
type: :development
|
40
39
|
prerelease: false
|
41
40
|
version_requirements: !ruby/object:Gem::Requirement
|
42
41
|
requirements:
|
43
42
|
- - "~>"
|
44
43
|
- !ruby/object:Gem::Version
|
45
|
-
version: 3.5
|
46
|
-
- !ruby/object:Gem::Dependency
|
47
|
-
name: webmock
|
48
|
-
requirement: !ruby/object:Gem::Requirement
|
49
|
-
requirements:
|
50
|
-
- - ">="
|
51
|
-
- !ruby/object:Gem::Version
|
52
|
-
version: '0'
|
53
|
-
type: :development
|
54
|
-
prerelease: false
|
55
|
-
version_requirements: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - ">="
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '0'
|
44
|
+
version: '3.5'
|
60
45
|
description: Manipulate images with minimal use of memory via ImageMagick
|
61
46
|
email:
|
62
47
|
- probablycorey@gmail.com
|
@@ -85,7 +70,6 @@ licenses:
|
|
85
70
|
- MIT
|
86
71
|
metadata:
|
87
72
|
changelog_uri: https://github.com/minimagick/minimagick/releases
|
88
|
-
post_install_message:
|
89
73
|
rdoc_options: []
|
90
74
|
require_paths:
|
91
75
|
- lib
|
@@ -101,8 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
101
85
|
version: '0'
|
102
86
|
requirements:
|
103
87
|
- You must have ImageMagick installed
|
104
|
-
rubygems_version: 3.
|
105
|
-
signing_key:
|
88
|
+
rubygems_version: 3.6.2
|
106
89
|
specification_version: 4
|
107
90
|
summary: Manipulate images with minimal use of memory via ImageMagick
|
108
91
|
test_files: []
|