mini_magick 5.0.1 → 5.1.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b2745570a5fe6e4da7ac8ab1cac8ad6799d6790893d1a1b626835f2e64f81f89
4
- data.tar.gz: 4a3d182ac394001a77df8f137f48b8f46fd2e85d4bd60d08d5ef04c44949675d
3
+ metadata.gz: fc9f02ad5d36f4550df15f5b46d097366ba7739a06fe94d2dfd70b9c954d3f82
4
+ data.tar.gz: 7238bd4a7b8ce456ed45e98badca0fcf6980adb4b0c75b33eacd25715a1c4982
5
5
  SHA512:
6
- metadata.gz: aaa65a8d47dd6c558d4207d0412f25bcf1ffcc79bcab07be9f6ca973bb175de9d57288a3348aa16bc85606647e499390e291878b12cdfda36ce14609ac5fb75b
7
- data.tar.gz: '0584062e993c3330236f84a0e91ef88ca36441c92bd81a6f3de35b89feefdc53a04d93613e0e684c847c65875367321f5f8565758b6ade5d5ca6737f45922149'
6
+ metadata.gz: d115ccae37b71bd42dabe8b3666c94d2cff39634b71ffae2bab2523bdcc2c863303213231c96845824c9708ba80c9ef7d1cad51540cbd41da467991664f8b005
7
+ data.tar.gz: d1c335fe66449b4134cc2ba50d3c4fa8fd86c23adcb7f3302fa4d05bea95051fb6640e638c91f14c90ae620500abbf9450105bae37e82dac5f6cc3a054010e2e
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. However, you can still configure MiniMagick to use it:
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.cli_prefix = "gm"
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 variables in your application's process environment:
477
+ setting the following:
474
478
 
475
- * `MAGICK_MEMORY_LIMIT=128MiB`
476
- * `MAGICK_MAP_LIMIT=64MiB`
477
- * `MAGICK_TIME_LIMIT=30`
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 a full list of variables and description, see [ImageMagick's resources
480
- documentation](http://www.imagemagick.org/script/resources.php#environment).
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
  ##
@@ -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({ "MAGICK_TIME_LIMIT" => timeout&.to_s }, *command, stdin_data: stdin)
35
+ Open3.capture3(env, *command, stdin_data: stdin)
32
36
  end
33
37
 
34
38
  [stdout, stderr, status&.exitstatus]
@@ -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
- Array(MiniMagick.cli_prefix).reverse_each { |p| exe.unshift p } if MiniMagick.cli_prefix
127
+ exe.unshift *Array(MiniMagick.cli_prefix)
127
128
  exe
128
129
  end
129
130
 
@@ -8,7 +8,7 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 5
11
- MINOR = 0
11
+ MINOR = 1
12
12
  TINY = 1
13
13
  PRE = nil
14
14
 
data/lib/mini_magick.rb CHANGED
@@ -17,6 +17,7 @@ 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
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.1
4
+ version: 5.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Johnson
@@ -10,19 +10,18 @@ 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: 2024-07-24 00:00:00.000000000 Z
15
+ date: 2025-02-01 00:00:00.000000000 Z
17
16
  dependencies:
18
17
  - !ruby/object:Gem::Dependency
19
- name: rake
18
+ name: logger
20
19
  requirement: !ruby/object:Gem::Requirement
21
20
  requirements:
22
21
  - - ">="
23
22
  - !ruby/object:Gem::Version
24
23
  version: '0'
25
- type: :development
24
+ type: :runtime
26
25
  prerelease: false
27
26
  version_requirements: !ruby/object:Gem::Requirement
28
27
  requirements:
@@ -30,33 +29,33 @@ dependencies:
30
29
  - !ruby/object:Gem::Version
31
30
  version: '0'
32
31
  - !ruby/object:Gem::Dependency
33
- name: rspec
32
+ name: rake
34
33
  requirement: !ruby/object:Gem::Requirement
35
34
  requirements:
36
- - - "~>"
35
+ - - ">="
37
36
  - !ruby/object:Gem::Version
38
- version: '3.5'
37
+ version: '0'
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'
44
+ version: '0'
46
45
  - !ruby/object:Gem::Dependency
47
- name: webmock
46
+ name: rspec
48
47
  requirement: !ruby/object:Gem::Requirement
49
48
  requirements:
50
- - - ">="
49
+ - - "~>"
51
50
  - !ruby/object:Gem::Version
52
- version: '0'
51
+ version: '3.5'
53
52
  type: :development
54
53
  prerelease: false
55
54
  version_requirements: !ruby/object:Gem::Requirement
56
55
  requirements:
57
- - - ">="
56
+ - - "~>"
58
57
  - !ruby/object:Gem::Version
59
- version: '0'
58
+ version: '3.5'
60
59
  description: Manipulate images with minimal use of memory via ImageMagick
61
60
  email:
62
61
  - probablycorey@gmail.com
@@ -85,7 +84,6 @@ licenses:
85
84
  - MIT
86
85
  metadata:
87
86
  changelog_uri: https://github.com/minimagick/minimagick/releases
88
- post_install_message:
89
87
  rdoc_options: []
90
88
  require_paths:
91
89
  - lib
@@ -101,8 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
101
99
  version: '0'
102
100
  requirements:
103
101
  - You must have ImageMagick installed
104
- rubygems_version: 3.5.11
105
- signing_key:
102
+ rubygems_version: 3.6.2
106
103
  specification_version: 4
107
104
  summary: Manipulate images with minimal use of memory via ImageMagick
108
105
  test_files: []