mini_magick 5.0.1 → 5.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +26 -9
- data/lib/mini_magick/configuration.rb +19 -0
- data/lib/mini_magick/shell.rb +5 -1
- data/lib/mini_magick/tool.rb +2 -1
- data/lib/mini_magick/version.rb +2 -2
- data/lib/mini_magick.rb +1 -0
- metadata +3 -20
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
@@ -240,6 +240,7 @@ 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
|
|
@@ -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/shell.rb
CHANGED
@@ -27,8 +27,12 @@ module MiniMagick
|
|
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
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.0
|
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
|
@@ -43,20 +42,6 @@ dependencies:
|
|
43
42
|
- - "~>"
|
44
43
|
- !ruby/object:Gem::Version
|
45
44
|
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'
|
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: []
|