mini_magick 3.7.0 → 4.11.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 +5 -5
- data/Rakefile +3 -3
- data/lib/mini_gmagick.rb +1 -0
- data/lib/mini_magick/configuration.rb +190 -0
- data/lib/mini_magick/image/info.rb +202 -0
- data/lib/mini_magick/image.rb +540 -311
- data/lib/mini_magick/shell.rb +81 -0
- data/lib/mini_magick/tool/animate.rb +14 -0
- data/lib/mini_magick/tool/compare.rb +14 -0
- data/lib/mini_magick/tool/composite.rb +14 -0
- data/lib/mini_magick/tool/conjure.rb +14 -0
- data/lib/mini_magick/tool/convert.rb +14 -0
- data/lib/mini_magick/tool/display.rb +14 -0
- data/lib/mini_magick/tool/identify.rb +14 -0
- data/lib/mini_magick/tool/import.rb +14 -0
- data/lib/mini_magick/tool/magick.rb +14 -0
- data/lib/mini_magick/tool/mogrify.rb +14 -0
- data/lib/mini_magick/tool/mogrify_restricted.rb +15 -0
- data/lib/mini_magick/tool/montage.rb +14 -0
- data/lib/mini_magick/tool/stream.rb +14 -0
- data/lib/mini_magick/tool.rb +307 -0
- data/lib/mini_magick/utilities.rb +25 -21
- data/lib/mini_magick/version.rb +15 -1
- data/lib/mini_magick.rb +54 -70
- metadata +65 -30
- data/lib/mini_magick/command_builder.rb +0 -104
- data/lib/mini_magick/errors.rb +0 -4
data/lib/mini_magick.rb
CHANGED
@@ -1,80 +1,64 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'stringio'
|
4
|
-
require 'pathname'
|
5
|
-
require 'shellwords'
|
6
|
-
require 'mini_magick/command_builder'
|
7
|
-
require 'mini_magick/errors'
|
8
|
-
require 'mini_magick/image'
|
9
|
-
require 'mini_magick/utilities'
|
1
|
+
require 'mini_magick/version'
|
2
|
+
require 'mini_magick/configuration'
|
10
3
|
|
11
4
|
module MiniMagick
|
12
|
-
class << self
|
13
|
-
attr_accessor :processor
|
14
|
-
attr_accessor :processor_path
|
15
|
-
attr_accessor :timeout
|
16
5
|
|
17
|
-
|
18
|
-
# Tries to detect the current processor based if any of the processors exist.
|
19
|
-
# Mogrify have precedence over gm by default.
|
20
|
-
#
|
21
|
-
# === Returns
|
22
|
-
# * [String] The detected procesor
|
23
|
-
def choose_processor
|
24
|
-
if MiniMagick::Utilities.which('mogrify').size > 0
|
25
|
-
self.processor = 'mogrify'
|
26
|
-
elsif MiniMagick::Utilities.which('gm').size > 0
|
27
|
-
self.processor = "gm"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
##
|
32
|
-
# Discovers the imagemagick version based on mogrify's output.
|
33
|
-
#
|
34
|
-
# === Returns
|
35
|
-
# * The imagemagick version
|
36
|
-
def image_magick_version
|
37
|
-
@@version ||= Gem::Version.create(`mogrify --version`.split(" ")[2].split("-").first)
|
38
|
-
end
|
39
|
-
|
40
|
-
##
|
41
|
-
# The minimum allowed imagemagick version
|
42
|
-
#
|
43
|
-
# === Returns
|
44
|
-
# * The minimum imagemagick version
|
45
|
-
def minimum_image_magick_version
|
46
|
-
@@minimum_version ||= Gem::Version.create("6.6.3")
|
47
|
-
end
|
6
|
+
extend MiniMagick::Configuration
|
48
7
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
8
|
+
##
|
9
|
+
# You might want to execute only certain blocks of processing with a
|
10
|
+
# different CLI, because for example that CLI does that particular thing
|
11
|
+
# faster. After the block CLI resets to its previous value.
|
12
|
+
#
|
13
|
+
# @example
|
14
|
+
# MiniMagick.with_cli :graphicsmagick do
|
15
|
+
# # operations that are better done with GraphicsMagick
|
16
|
+
# end
|
17
|
+
def self.with_cli(cli)
|
18
|
+
old_cli = self.cli
|
19
|
+
self.cli = cli
|
20
|
+
yield
|
21
|
+
ensure
|
22
|
+
self.cli = old_cli
|
23
|
+
end
|
57
24
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
25
|
+
##
|
26
|
+
# Checks whether the CLI used is ImageMagick.
|
27
|
+
#
|
28
|
+
# @return [Boolean]
|
29
|
+
def self.imagemagick?
|
30
|
+
cli == :imagemagick
|
31
|
+
end
|
65
32
|
|
66
|
-
|
67
|
-
|
33
|
+
##
|
34
|
+
# Checks whether the CLI used is ImageMagick 7.
|
35
|
+
#
|
36
|
+
# @return [Boolean]
|
37
|
+
def self.imagemagick7?
|
38
|
+
cli == :imagemagick7
|
39
|
+
end
|
68
40
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
41
|
+
##
|
42
|
+
# Checks whether the CLI used is GraphicsMagick.
|
43
|
+
#
|
44
|
+
# @return [Boolean]
|
45
|
+
def self.graphicsmagick?
|
46
|
+
cli == :graphicsmagick
|
47
|
+
end
|
76
48
|
|
77
|
-
|
78
|
-
|
49
|
+
##
|
50
|
+
# Returns ImageMagick's/GraphicsMagick's version.
|
51
|
+
#
|
52
|
+
# @return [String]
|
53
|
+
def self.cli_version
|
54
|
+
output = MiniMagick::Tool::Identify.new(&:version)
|
55
|
+
output[/\d+\.\d+\.\d+(-\d+)?/]
|
79
56
|
end
|
57
|
+
|
58
|
+
class Error < RuntimeError; end
|
59
|
+
class Invalid < StandardError; end
|
60
|
+
|
80
61
|
end
|
62
|
+
|
63
|
+
require 'mini_magick/tool'
|
64
|
+
require 'mini_magick/image'
|
metadata
CHANGED
@@ -1,92 +1,112 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.11.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Johnson
|
8
8
|
- Hampton Catlin
|
9
9
|
- Peter Kieltyka
|
10
|
+
- James Miller
|
11
|
+
- Thiago Fernandes Massa
|
12
|
+
- Janko Marohnić
|
10
13
|
autorequire:
|
11
14
|
bindir: bin
|
12
15
|
cert_chain: []
|
13
|
-
date:
|
16
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
14
17
|
dependencies:
|
15
18
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
19
|
+
name: rake
|
17
20
|
requirement: !ruby/object:Gem::Requirement
|
18
21
|
requirements:
|
19
|
-
- -
|
22
|
+
- - ">="
|
20
23
|
- !ruby/object:Gem::Version
|
21
|
-
version: 0
|
22
|
-
type: :
|
24
|
+
version: '0'
|
25
|
+
type: :development
|
23
26
|
prerelease: false
|
24
27
|
version_requirements: !ruby/object:Gem::Requirement
|
25
28
|
requirements:
|
26
|
-
- -
|
29
|
+
- - ">="
|
27
30
|
- !ruby/object:Gem::Version
|
28
|
-
version: 0
|
31
|
+
version: '0'
|
29
32
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
33
|
+
name: rspec
|
31
34
|
requirement: !ruby/object:Gem::Requirement
|
32
35
|
requirements:
|
33
|
-
- -
|
36
|
+
- - "~>"
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 3.5.0
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
requirements:
|
43
|
+
- - "~>"
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 3.5.0
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
requirements:
|
50
|
+
- - ">="
|
34
51
|
- !ruby/object:Gem::Version
|
35
52
|
version: '0'
|
36
53
|
type: :development
|
37
54
|
prerelease: false
|
38
55
|
version_requirements: !ruby/object:Gem::Requirement
|
39
56
|
requirements:
|
40
|
-
- -
|
57
|
+
- - ">="
|
41
58
|
- !ruby/object:Gem::Version
|
42
59
|
version: '0'
|
43
60
|
- !ruby/object:Gem::Dependency
|
44
|
-
name:
|
61
|
+
name: guard-rspec
|
45
62
|
requirement: !ruby/object:Gem::Requirement
|
46
63
|
requirements:
|
47
|
-
- -
|
64
|
+
- - ">="
|
48
65
|
- !ruby/object:Gem::Version
|
49
66
|
version: '0'
|
50
67
|
type: :development
|
51
68
|
prerelease: false
|
52
69
|
version_requirements: !ruby/object:Gem::Requirement
|
53
70
|
requirements:
|
54
|
-
- -
|
71
|
+
- - ">="
|
55
72
|
- !ruby/object:Gem::Version
|
56
73
|
version: '0'
|
57
74
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
75
|
+
name: posix-spawn
|
59
76
|
requirement: !ruby/object:Gem::Requirement
|
60
77
|
requirements:
|
61
|
-
- -
|
78
|
+
- - ">="
|
62
79
|
- !ruby/object:Gem::Version
|
63
80
|
version: '0'
|
64
81
|
type: :development
|
65
82
|
prerelease: false
|
66
83
|
version_requirements: !ruby/object:Gem::Requirement
|
67
84
|
requirements:
|
68
|
-
- -
|
85
|
+
- - ">="
|
69
86
|
- !ruby/object:Gem::Version
|
70
87
|
version: '0'
|
71
88
|
- !ruby/object:Gem::Dependency
|
72
|
-
name:
|
89
|
+
name: webmock
|
73
90
|
requirement: !ruby/object:Gem::Requirement
|
74
91
|
requirements:
|
75
|
-
- -
|
92
|
+
- - ">="
|
76
93
|
- !ruby/object:Gem::Version
|
77
94
|
version: '0'
|
78
95
|
type: :development
|
79
96
|
prerelease: false
|
80
97
|
version_requirements: !ruby/object:Gem::Requirement
|
81
98
|
requirements:
|
82
|
-
- -
|
99
|
+
- - ">="
|
83
100
|
- !ruby/object:Gem::Version
|
84
101
|
version: '0'
|
85
|
-
description:
|
102
|
+
description: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
|
86
103
|
email:
|
87
104
|
- probablycorey@gmail.com
|
88
105
|
- hcatlin@gmail.com
|
89
106
|
- peter@nulayer.com
|
107
|
+
- bensie@gmail.com
|
108
|
+
- thiagown@gmail.com
|
109
|
+
- janko.marohnic@gmail.com
|
90
110
|
executables: []
|
91
111
|
extensions: []
|
92
112
|
extra_rdoc_files: []
|
@@ -94,14 +114,30 @@ files:
|
|
94
114
|
- MIT-LICENSE
|
95
115
|
- Rakefile
|
96
116
|
- lib/mini_gmagick.rb
|
97
|
-
- lib/mini_magick
|
98
|
-
- lib/mini_magick/
|
117
|
+
- lib/mini_magick.rb
|
118
|
+
- lib/mini_magick/configuration.rb
|
99
119
|
- lib/mini_magick/image.rb
|
120
|
+
- lib/mini_magick/image/info.rb
|
121
|
+
- lib/mini_magick/shell.rb
|
122
|
+
- lib/mini_magick/tool.rb
|
123
|
+
- lib/mini_magick/tool/animate.rb
|
124
|
+
- lib/mini_magick/tool/compare.rb
|
125
|
+
- lib/mini_magick/tool/composite.rb
|
126
|
+
- lib/mini_magick/tool/conjure.rb
|
127
|
+
- lib/mini_magick/tool/convert.rb
|
128
|
+
- lib/mini_magick/tool/display.rb
|
129
|
+
- lib/mini_magick/tool/identify.rb
|
130
|
+
- lib/mini_magick/tool/import.rb
|
131
|
+
- lib/mini_magick/tool/magick.rb
|
132
|
+
- lib/mini_magick/tool/mogrify.rb
|
133
|
+
- lib/mini_magick/tool/mogrify_restricted.rb
|
134
|
+
- lib/mini_magick/tool/montage.rb
|
135
|
+
- lib/mini_magick/tool/stream.rb
|
100
136
|
- lib/mini_magick/utilities.rb
|
101
137
|
- lib/mini_magick/version.rb
|
102
|
-
- lib/mini_magick.rb
|
103
138
|
homepage: https://github.com/minimagick/minimagick
|
104
|
-
licenses:
|
139
|
+
licenses:
|
140
|
+
- MIT
|
105
141
|
metadata: {}
|
106
142
|
post_install_message:
|
107
143
|
rdoc_options: []
|
@@ -109,18 +145,17 @@ require_paths:
|
|
109
145
|
- lib
|
110
146
|
required_ruby_version: !ruby/object:Gem::Requirement
|
111
147
|
requirements:
|
112
|
-
- -
|
148
|
+
- - ">="
|
113
149
|
- !ruby/object:Gem::Version
|
114
|
-
version: '0'
|
150
|
+
version: '2.0'
|
115
151
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
116
152
|
requirements:
|
117
|
-
- -
|
153
|
+
- - ">="
|
118
154
|
- !ruby/object:Gem::Version
|
119
155
|
version: '0'
|
120
156
|
requirements:
|
121
157
|
- You must have ImageMagick or GraphicsMagick installed
|
122
|
-
|
123
|
-
rubygems_version: 2.0.3
|
158
|
+
rubygems_version: 3.1.4
|
124
159
|
signing_key:
|
125
160
|
specification_version: 4
|
126
161
|
summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
|
@@ -1,104 +0,0 @@
|
|
1
|
-
module MiniMagick
|
2
|
-
class CommandBuilder
|
3
|
-
MOGRIFY_COMMANDS = %w{adaptive-blur adaptive-resize adaptive-sharpen adjoin affine alpha annotate antialias append attenuate authenticate auto-gamma auto-level auto-orient backdrop background bench bias black-point-compensation black-threshold blend blue-primary blue-shift blur border bordercolor borderwidth brightness-contrast cache caption cdl channel charcoal chop clamp clip clip-mask clip-path clone clut coalesce colorize colormap color-matrix colors colorspace combine comment compose composite compress contrast contrast-stretch convolve crop cycle debug decipher deconstruct define delay delete density depth descend deskew despeckle direction displace display dispose dissimilarity-threshold dissolve distort dither draw duplicate edge emboss encipher encoding endian enhance equalize evaluate evaluate-sequence extent extract family features fft fill filter flatten flip floodfill flop font foreground format frame function fuzz fx gamma gaussian-blur geometry gravity green-primary hald-clut help highlight-color iconGeometry iconic identify ift immutable implode insert intent interlace interpolate interline-spacing interword-spacing kerning label lat layers level level-colors limit linear-stretch linewidth liquid-rescale list log loop lowlight-color magnify map mask mattecolor median metric mode modulate monitor monochrome morph morphology mosaic motion-blur name negate noise normalize opaque ordered-dither orient page paint path pause pen perceptible ping pointsize polaroid poly posterize precision preview print process profile quality quantize quiet radial-blur raise random-threshold red-primary regard-warnings region remap remote render repage resample resize respect-parentheses reverse roll rotate sample sampling-factor scale scene screen seed segment selective-blur separate sepia-tone set shade shadow shared-memory sharpen shave shear sigmoidal-contrast silent size sketch smush snaps solarize sparse-color splice spread statistic stegano stereo stretch strip stroke strokewidth style subimage-search swap swirl synchronize taint text-font texture threshold thumbnail tile tile-offset tint title transform transparent transparent-color transpose transverse treedepth trim type undercolor unique-colors units unsharp update verbose version view vignette virtual-pixel visual watermark wave weight white-point white-threshold window window-group write}
|
4
|
-
IMAGE_CREATION_OPERATORS = %w{canvas caption gradient label logo pattern plasma radial radient rose text tile xc }
|
5
|
-
|
6
|
-
def initialize(tool, *options)
|
7
|
-
@tool = tool
|
8
|
-
@args = []
|
9
|
-
options.each { |arg| push(arg) }
|
10
|
-
end
|
11
|
-
|
12
|
-
def command
|
13
|
-
com = "#{@tool} #{args.join(' ')}".strip
|
14
|
-
com = "#{MiniMagick.processor} #{com}" unless MiniMagick.mogrify?
|
15
|
-
|
16
|
-
com = File.join MiniMagick.processor_path, com unless MiniMagick.processor_path.nil?
|
17
|
-
com.strip
|
18
|
-
end
|
19
|
-
|
20
|
-
def escape_string_windows(value)
|
21
|
-
# For Windows, ^ is the escape char, equivalent to \ in Unix.
|
22
|
-
escaped = value.gsub(/\^/, '^^').gsub(/>/, '^>')
|
23
|
-
if escaped !~ /^".+"$/ && escaped.include?("'")
|
24
|
-
escaped.inspect
|
25
|
-
else
|
26
|
-
escaped
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
def args
|
32
|
-
if !MiniMagick::Utilities.windows?
|
33
|
-
@args.map(&:shellescape)
|
34
|
-
else
|
35
|
-
@args.map { |arg| escape_string_windows(arg) }
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# Add each mogrify command in both underscore and dash format
|
40
|
-
MOGRIFY_COMMANDS.each do |mogrify_command|
|
41
|
-
|
42
|
-
# Example of what is generated here:
|
43
|
-
#
|
44
|
-
# def auto_orient(*options)
|
45
|
-
# add_command("auto-orient", *options)
|
46
|
-
# self
|
47
|
-
# end
|
48
|
-
# alias_method :"auto-orient", :auto_orient
|
49
|
-
|
50
|
-
dashed_command = mogrify_command.to_s.gsub("_","-")
|
51
|
-
underscored_command = mogrify_command.to_s.gsub("-","_")
|
52
|
-
|
53
|
-
define_method(underscored_command) do |*options|
|
54
|
-
add_command(__method__.to_s.gsub("_","-"), *options)
|
55
|
-
self
|
56
|
-
end
|
57
|
-
alias_method dashed_command, underscored_command
|
58
|
-
end
|
59
|
-
|
60
|
-
def format(*options)
|
61
|
-
raise Error, "You must call 'format' on the image object directly!"
|
62
|
-
end
|
63
|
-
|
64
|
-
IMAGE_CREATION_OPERATORS.each do |operator|
|
65
|
-
define_method operator do |*options|
|
66
|
-
add_creation_operator(__method__.to_s, *options)
|
67
|
-
self
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
def +(*options)
|
72
|
-
push(@args.pop.gsub(/^-/, '+'))
|
73
|
-
if options.any?
|
74
|
-
options.each do |o|
|
75
|
-
push o
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
def add_command(command, *options)
|
81
|
-
push "-#{command}"
|
82
|
-
if options.any?
|
83
|
-
options.each do |o|
|
84
|
-
push o
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
def add_creation_operator(command, *options)
|
90
|
-
creation_command = command
|
91
|
-
if options.any?
|
92
|
-
options.each do |option|
|
93
|
-
creation_command << ":#{option}"
|
94
|
-
end
|
95
|
-
end
|
96
|
-
push creation_command
|
97
|
-
end
|
98
|
-
|
99
|
-
def push(arg)
|
100
|
-
@args << arg.to_s.strip
|
101
|
-
end
|
102
|
-
alias :<< :push
|
103
|
-
end
|
104
|
-
end
|
data/lib/mini_magick/errors.rb
DELETED