mojo_magick 0.5.3 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +24 -0
- data/.github/dependabot.yml +8 -0
- data/.rubocop-common.yml +99 -0
- data/.rubocop-performance.yml +2 -0
- data/.rubocop-rspec.yml +33 -0
- data/.rubocop.yml +10 -0
- data/.ruby-version +1 -1
- data/Gemfile +6 -1
- data/Gemfile.lock +58 -10
- data/LICENSE.txt +1 -1
- data/README.md +50 -2
- data/Rakefile +15 -12
- data/examples/animated_gif.rb +11 -14
- data/examples/composite.rb +11 -14
- data/init.rb +1 -3
- data/lib/image_magick/fonts.rb +6 -6
- data/lib/initializers/hash.rb +5 -1
- data/lib/mojo_magick.rb +191 -186
- data/lib/mojo_magick/command_status.rb +11 -0
- data/lib/mojo_magick/errors.rb +5 -0
- data/lib/mojo_magick/font.rb +4 -6
- data/lib/mojo_magick/opt_builder.rb +23 -32
- data/lib/mojo_magick/util/parser.rb +7 -48
- data/lib/mojo_magick/version.rb +1 -1
- data/mojo_magick.gemspec +21 -16
- data/test/fixtures/roll with it.jpg +0 -0
- data/test/font_test.rb +22 -28
- data/test/fonts_test.rb +4 -5
- data/test/mojo_magick_test.rb +282 -256
- data/test/opt_builder_test.rb +46 -49
- data/test/parser_test.rb +17 -18
- data/test/test_helper.rb +7 -5
- metadata +87 -25
- data/lib/image_magick/resource_limits.rb +0 -94
- data/lib/image_resources.rb +0 -0
- data/test/resource_limits_test.rb +0 -51
data/test/opt_builder_test.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
|
1
|
+
require_relative "test_helper"
|
4
2
|
|
3
|
+
class MojoMagickOptBuilderTest < MiniTest::Test
|
5
4
|
# These tests make the assumption that if we call #raw_command with the
|
6
5
|
# correct strings, ImageMagick itself will operate correctly. We're only
|
7
6
|
# verifying that the option builder produces the correct strings
|
@@ -11,36 +10,36 @@ class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_annotate
|
14
|
-
@builder.annotate
|
15
|
-
assert_equal
|
13
|
+
@builder.annotate "blah"
|
14
|
+
assert_equal %w[-annotate 0 blah], @builder.to_a
|
16
15
|
end
|
17
16
|
|
18
17
|
def test_annotate_with_escapeable_string
|
19
|
-
@builder.annotate
|
20
|
-
assert_equal
|
18
|
+
@builder.annotate "it's"
|
19
|
+
assert_equal %w[-annotate 0 it's], @builder.to_a
|
21
20
|
end
|
22
21
|
|
23
22
|
def test_annotate_with_full_args
|
24
|
-
@builder.annotate
|
25
|
-
assert_equal
|
23
|
+
@builder.annotate "5 it's"
|
24
|
+
assert_equal %w[-annotate 5 it's], @builder.to_a
|
26
25
|
end
|
27
26
|
|
28
27
|
def test_option_builder_with_blocks
|
29
28
|
# Passing in basic commands produces a string
|
30
29
|
b = MojoMagick::OptBuilder.new
|
31
30
|
b.image_block do
|
32
|
-
b.background
|
31
|
+
b.background "red"
|
33
32
|
end
|
34
33
|
b.image_block do
|
35
|
-
b.background
|
34
|
+
b.background "blue"
|
36
35
|
end
|
37
|
-
assert_equal '\( -background red \) \( -background blue \)', b.
|
36
|
+
assert_equal ['\(', "-background", "red", '\)', '\(', "-background", "blue", '\)'], b.to_a
|
38
37
|
end
|
39
38
|
|
40
|
-
def test_option_builder_with_hex_colors
|
39
|
+
def test_option_builder_with_hex_colors
|
41
40
|
b = MojoMagick::OptBuilder.new
|
42
|
-
b.background
|
43
|
-
assert_equal
|
41
|
+
b.background "#000000"
|
42
|
+
assert_equal %w[-background #000000], b.to_a
|
44
43
|
end
|
45
44
|
|
46
45
|
def test_option_builder
|
@@ -48,85 +47,83 @@ class MojoMagickOptBuilderTest < MiniTest::Unit::TestCase
|
|
48
47
|
b = MojoMagick::OptBuilder.new
|
49
48
|
b.strip
|
50
49
|
b.repage
|
51
|
-
assert_equal
|
50
|
+
assert_equal "-strip -repage", b.to_s
|
52
51
|
|
53
52
|
# Chaining commands works
|
54
53
|
b = MojoMagick::OptBuilder.new.strip.repage
|
55
|
-
assert_equal
|
54
|
+
assert_equal "-strip -repage", b.to_s
|
56
55
|
|
57
56
|
# Bang (!) indicates the plus version of commands
|
58
57
|
b = MojoMagick::OptBuilder.new
|
59
58
|
b.repage
|
60
59
|
b.repage!
|
61
|
-
assert_equal
|
60
|
+
assert_equal "-repage +repage", b.to_s
|
62
61
|
|
63
62
|
# Accepts raw data as-is
|
64
63
|
b = MojoMagick::OptBuilder.new
|
65
64
|
b.opt1
|
66
|
-
b <<
|
65
|
+
b << "a ! b !"
|
67
66
|
b.opt2
|
68
|
-
assert_equal
|
67
|
+
assert_equal "-opt1 a ! b ! -opt2", b.to_s
|
69
68
|
|
70
69
|
# Treats an array of raw data as different arguments
|
71
70
|
b = MojoMagick::OptBuilder.new
|
72
|
-
b << [
|
73
|
-
assert_equal
|
71
|
+
b << ["leave this data", "alone"]
|
72
|
+
assert_equal "leave this data alone", b.to_s
|
74
73
|
|
75
74
|
# String includes command arguments
|
76
75
|
b = MojoMagick::OptBuilder.new
|
77
|
-
b.extent
|
78
|
-
b.crop
|
79
|
-
assert_equal
|
76
|
+
b.extent "256x256+0+0"
|
77
|
+
b.crop "64x64"
|
78
|
+
assert_equal %w[-extent 256x256+0+0 -crop 64x64], b.to_a
|
80
79
|
|
81
80
|
# Arguments are quoted (doublequote) if appropriate
|
82
81
|
b = MojoMagick::OptBuilder.new
|
83
|
-
b.comment
|
84
|
-
b.comment
|
85
|
-
b.crop
|
86
|
-
assert_equal
|
82
|
+
b.comment "white space"
|
83
|
+
b.comment "w&b"
|
84
|
+
b.crop "6x6^"
|
85
|
+
assert_equal ["-comment", "white space", "-comment", "w&b", "-crop", "6x6^"], b.to_a
|
87
86
|
|
88
87
|
# Existing doublequotes are escaped
|
89
88
|
b = MojoMagick::OptBuilder.new
|
90
89
|
b.comment 'Fred "Woot" Rook'
|
91
|
-
assert_equal
|
90
|
+
assert_equal ["-comment", "Fred \"Woot\" Rook"], b.to_a
|
92
91
|
|
93
92
|
# Multi-argument commands should not be quoted together
|
94
93
|
b = MojoMagick::OptBuilder.new
|
95
|
-
b.set
|
96
|
-
assert_equal
|
94
|
+
b.set "comment", 'the "best" comment'
|
95
|
+
assert_equal ["-set", "comment", "the \"best\" comment"], b.to_a
|
97
96
|
|
98
97
|
# File and files are helper methods
|
99
98
|
b = MojoMagick::OptBuilder.new
|
100
|
-
b.files
|
99
|
+
b.files "source.jpg", "source2.jpg"
|
101
100
|
b.append
|
102
|
-
b.crop
|
103
|
-
b.file
|
104
|
-
assert_equal
|
101
|
+
b.crop "64x64"
|
102
|
+
b.file "dest%d.jpg"
|
103
|
+
assert_equal %w[source.jpg source2.jpg -append -crop 64x64 dest%d.jpg], b.to_a
|
105
104
|
|
106
105
|
# Files are quoted (doublequote) if appropriate
|
107
106
|
b = MojoMagick::OptBuilder.new
|
108
|
-
b.file
|
109
|
-
assert_equal
|
107
|
+
b.file "probably on windows.jpg"
|
108
|
+
assert_equal ["probably on windows.jpg"], b.to_a
|
110
109
|
|
111
110
|
# Blob is a shortcut for the #tempfile helper method
|
112
111
|
b = MojoMagick::OptBuilder.new
|
113
|
-
b.blob
|
112
|
+
b.blob "binary data"
|
114
113
|
filename = b.to_s
|
115
|
-
File.open(filename,
|
116
|
-
assert_equal f.read
|
114
|
+
File.open(filename, "rb") do |f|
|
115
|
+
assert_equal "binary data", f.read
|
117
116
|
end
|
118
117
|
|
119
|
-
#label for text should use 'label:"the string"' if specified
|
120
|
-
[[
|
121
|
-
[
|
122
|
-
[
|
123
|
-
[
|
124
|
-
[
|
125
|
-
|
118
|
+
# label for text should use 'label:"the string"' if specified
|
119
|
+
[%w[mylabel mylabel],
|
120
|
+
['my " label', '"my \" label"'],
|
121
|
+
["Rock it, cuz i said so!", '"Rock it, cuz i said so!"'],
|
122
|
+
["it's like this", '"it\'s like this"'],
|
123
|
+
["\#$%^&*", '"#$%^&*"']].each do |labels|
|
126
124
|
b = MojoMagick::OptBuilder.new
|
127
125
|
b.label labels[0]
|
128
126
|
assert_equal "label:#{labels[1]}", b.to_s
|
129
127
|
end
|
130
|
-
|
131
128
|
end
|
132
129
|
end
|
data/test/parser_test.rb
CHANGED
@@ -1,30 +1,29 @@
|
|
1
|
-
|
1
|
+
require_relative "test_helper"
|
2
2
|
|
3
|
-
IDENTIFY_FONT_RESPONSE
|
3
|
+
IDENTIFY_FONT_RESPONSE = <<~EOFONT
|
4
4
|
|
5
|
-
Font: Zapf-Dingbats
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
Font: Zapf-Dingbats
|
6
|
+
family: Zapf Dingbats
|
7
|
+
style: Normal
|
8
|
+
stretch: Normal
|
9
|
+
weight: 400
|
10
|
+
glyphs: /System/Library/Fonts/ZapfDingbats.ttf
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
12
|
+
Font: Zapfino
|
13
|
+
family: Zapfino
|
14
|
+
style: Italic
|
15
|
+
stretch: Normal
|
16
|
+
weight: 400
|
17
|
+
glyphs: /Library/Fonts/Zapfino.ttf
|
18
18
|
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
class ParserTest < MiniTest::Unit::TestCase
|
20
|
+
EOFONT
|
23
21
|
|
22
|
+
class ParserTest < MiniTest::Test
|
24
23
|
def test_parse_fonts
|
25
24
|
parser = MojoMagick::Util::Parser.new
|
26
25
|
parsed_fonts = parser.parse_fonts(IDENTIFY_FONT_RESPONSE)
|
27
26
|
assert_equal parsed_fonts.length, 2
|
28
|
-
assert_equal parsed_fonts[1].style,
|
27
|
+
assert_equal parsed_fonts[1].style, "Italic"
|
29
28
|
end
|
30
29
|
end
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
require 'fileutils'
|
4
|
-
require 'tempfile'
|
5
|
-
require 'rspec/expectations'
|
1
|
+
require "simplecov"
|
2
|
+
SimpleCov.start
|
6
3
|
|
4
|
+
require "minitest/autorun"
|
5
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "init"))
|
6
|
+
require "fileutils"
|
7
|
+
require "tempfile"
|
8
|
+
require "rspec/expectations"
|
metadata
CHANGED
@@ -1,69 +1,131 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojo_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Midgley
|
8
8
|
- Elliot Nelson
|
9
9
|
- Jon Rogers
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: bundler
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
requirements:
|
19
|
+
- - ">="
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
version: '0'
|
29
|
+
- !ruby/object:Gem::Dependency
|
30
|
+
name: bundle-audit
|
17
31
|
requirement: !ruby/object:Gem::Requirement
|
18
32
|
requirements:
|
19
|
-
- -
|
33
|
+
- - ">="
|
20
34
|
- !ruby/object:Gem::Version
|
21
35
|
version: '0'
|
22
36
|
type: :development
|
23
37
|
prerelease: false
|
24
38
|
version_requirements: !ruby/object:Gem::Requirement
|
25
39
|
requirements:
|
26
|
-
- -
|
40
|
+
- - ">="
|
27
41
|
- !ruby/object:Gem::Version
|
28
42
|
version: '0'
|
29
43
|
- !ruby/object:Gem::Dependency
|
30
|
-
name:
|
44
|
+
name: minitest
|
45
|
+
requirement: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '0'
|
50
|
+
type: :development
|
51
|
+
prerelease: false
|
52
|
+
version_requirements: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
- !ruby/object:Gem::Dependency
|
58
|
+
name: rake
|
31
59
|
requirement: !ruby/object:Gem::Requirement
|
32
60
|
requirements:
|
33
|
-
- -
|
61
|
+
- - ">="
|
34
62
|
- !ruby/object:Gem::Version
|
35
63
|
version: '0'
|
36
64
|
type: :development
|
37
65
|
prerelease: false
|
38
66
|
version_requirements: !ruby/object:Gem::Requirement
|
39
67
|
requirements:
|
40
|
-
- -
|
68
|
+
- - ">="
|
41
69
|
- !ruby/object:Gem::Version
|
42
70
|
version: '0'
|
43
71
|
- !ruby/object:Gem::Dependency
|
44
72
|
name: rspec-expectations
|
45
73
|
requirement: !ruby/object:Gem::Requirement
|
46
74
|
requirements:
|
47
|
-
- -
|
75
|
+
- - ">="
|
48
76
|
- !ruby/object:Gem::Version
|
49
77
|
version: '0'
|
50
78
|
type: :development
|
51
79
|
prerelease: false
|
52
80
|
version_requirements: !ruby/object:Gem::Requirement
|
53
81
|
requirements:
|
54
|
-
- -
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
- !ruby/object:Gem::Dependency
|
86
|
+
name: rubocop
|
87
|
+
requirement: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
92
|
+
type: :development
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: !ruby/object:Gem::Requirement
|
95
|
+
requirements:
|
96
|
+
- - ">="
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: '0'
|
99
|
+
- !ruby/object:Gem::Dependency
|
100
|
+
name: rubocop-performance
|
101
|
+
requirement: !ruby/object:Gem::Requirement
|
102
|
+
requirements:
|
103
|
+
- - ">="
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '0'
|
106
|
+
type: :development
|
107
|
+
prerelease: false
|
108
|
+
version_requirements: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
55
111
|
- !ruby/object:Gem::Version
|
56
112
|
version: '0'
|
57
113
|
description: Simple Ruby stateless module interface to imagemagick.
|
58
114
|
email:
|
59
|
-
-
|
115
|
+
- science@misuse.org
|
60
116
|
- jon@rcode5.com
|
61
117
|
executables: []
|
62
118
|
extensions: []
|
63
119
|
extra_rdoc_files: []
|
64
120
|
files:
|
65
|
-
- .
|
66
|
-
- .
|
121
|
+
- ".circleci/config.yml"
|
122
|
+
- ".github/dependabot.yml"
|
123
|
+
- ".gitignore"
|
124
|
+
- ".rubocop-common.yml"
|
125
|
+
- ".rubocop-performance.yml"
|
126
|
+
- ".rubocop-rspec.yml"
|
127
|
+
- ".rubocop.yml"
|
128
|
+
- ".ruby-version"
|
67
129
|
- Gemfile
|
68
130
|
- Gemfile.lock
|
69
131
|
- LICENSE.txt
|
@@ -73,10 +135,10 @@ files:
|
|
73
135
|
- examples/composite.rb
|
74
136
|
- init.rb
|
75
137
|
- lib/image_magick/fonts.rb
|
76
|
-
- lib/image_magick/resource_limits.rb
|
77
|
-
- lib/image_resources.rb
|
78
138
|
- lib/initializers/hash.rb
|
79
139
|
- lib/mojo_magick.rb
|
140
|
+
- lib/mojo_magick/command_status.rb
|
141
|
+
- lib/mojo_magick/errors.rb
|
80
142
|
- lib/mojo_magick/font.rb
|
81
143
|
- lib/mojo_magick/opt_builder.rb
|
82
144
|
- lib/mojo_magick/util/parser.rb
|
@@ -84,13 +146,13 @@ files:
|
|
84
146
|
- mojo_magick.gemspec
|
85
147
|
- test/fixtures/5742.jpg
|
86
148
|
- test/fixtures/not_an_image.jpg
|
149
|
+
- test/fixtures/roll with it.jpg
|
87
150
|
- test/fixtures/zero_byte_image.jpg
|
88
151
|
- test/font_test.rb
|
89
152
|
- test/fonts_test.rb
|
90
153
|
- test/mojo_magick_test.rb
|
91
154
|
- test/opt_builder_test.rb
|
92
155
|
- test/parser_test.rb
|
93
|
-
- test/resource_limits_test.rb
|
94
156
|
- test/test_helper.rb
|
95
157
|
homepage: http://github.com/rcode5/mojo_magick
|
96
158
|
licenses:
|
@@ -110,28 +172,28 @@ require_paths:
|
|
110
172
|
- lib
|
111
173
|
required_ruby_version: !ruby/object:Gem::Requirement
|
112
174
|
requirements:
|
113
|
-
- -
|
175
|
+
- - ">="
|
114
176
|
- !ruby/object:Gem::Version
|
115
|
-
version:
|
177
|
+
version: 2.6.0
|
116
178
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
179
|
requirements:
|
118
|
-
- -
|
180
|
+
- - ">="
|
119
181
|
- !ruby/object:Gem::Version
|
120
182
|
version: '0'
|
121
183
|
requirements: []
|
122
|
-
|
123
|
-
|
124
|
-
signing_key:
|
184
|
+
rubygems_version: 3.0.3
|
185
|
+
signing_key:
|
125
186
|
specification_version: 4
|
126
|
-
summary: mojo_magick-0.
|
187
|
+
summary: mojo_magick-0.6.0
|
127
188
|
test_files:
|
128
189
|
- test/fixtures/5742.jpg
|
129
190
|
- test/fixtures/not_an_image.jpg
|
191
|
+
- test/fixtures/roll with it.jpg
|
130
192
|
- test/fixtures/zero_byte_image.jpg
|
131
193
|
- test/font_test.rb
|
132
194
|
- test/fonts_test.rb
|
133
195
|
- test/mojo_magick_test.rb
|
134
196
|
- test/opt_builder_test.rb
|
135
197
|
- test/parser_test.rb
|
136
|
-
- test/resource_limits_test.rb
|
137
198
|
- test/test_helper.rb
|
199
|
+
...
|
@@ -1,94 +0,0 @@
|
|
1
|
-
# This module provides some mix-in methods to permit resource limitation commands in MojoMagick
|
2
|
-
module ImageMagick
|
3
|
-
module ResourceLimits
|
4
|
-
@@resource_limits = {}
|
5
|
-
|
6
|
-
# controls limits on memory and other resources for imagemagick.
|
7
|
-
# possible values for type can include:
|
8
|
-
# Area, Disk, File, Map, or Memory
|
9
|
-
# value is byte size for everything but Disk, where it's number of files
|
10
|
-
# type can be string or symbol.
|
11
|
-
# Just limiting Memory will not solve problems with imagemagick going out of
|
12
|
-
# control with resource consumption on certain bad files. You have to set disk,
|
13
|
-
# area and map limits too. Read up on imagemagick website for more.
|
14
|
-
# Different options have different units
|
15
|
-
# DISK: N GB
|
16
|
-
# AREA, MAP, MEMORY: N MB
|
17
|
-
# FILE: N num file handles
|
18
|
-
# Examples:
|
19
|
-
# # set disk to 5 gigabytes limit
|
20
|
-
# MiniMagick::Image::set_limit(:disk => 5)
|
21
|
-
# # set memory to 32mb, map to 64mb and disk to 0
|
22
|
-
# MiniMagick::Image::set_limit(:memory => 32, 'map' => 64, 'disk' => 0)
|
23
|
-
def set_limits(options)
|
24
|
-
mem_fix = 1
|
25
|
-
options.each do |resource, value|
|
26
|
-
@@resource_limits[resource.to_s.downcase.to_sym] = value.to_s
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
# remove a limit
|
31
|
-
def remove_limits(*options)
|
32
|
-
mem_fix = 1
|
33
|
-
@@resource_limits.delete_if do |resource, value|
|
34
|
-
idx = options.index(resource)
|
35
|
-
resource == options.values_at(idx)[0].to_s.downcase.to_sym if idx
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
# remove limits from resources
|
40
|
-
def unset_limits(options = {})
|
41
|
-
mem_fix = 1
|
42
|
-
@@resource_limits = {}
|
43
|
-
if options[:unset_env]
|
44
|
-
ENV["MAGICK_AREA_LIMIT"]=nil
|
45
|
-
ENV["MAGICK_MAP_LIMIT"]=nil
|
46
|
-
ENV["MAGICK_MEMORY_LIMIT"]=nil
|
47
|
-
ENV["MAGICK_DISK_LIMIT"]=nil
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
# returns the default limits that imagemagick is using, when run with no "-limit" parameters
|
52
|
-
# options:
|
53
|
-
# :show_actual_values => true (default false) - will return integers instead of readable values
|
54
|
-
def get_default_limits(options = {})
|
55
|
-
mem_fix = 1
|
56
|
-
parse_limits(options.merge(:get_current_limits => false))
|
57
|
-
end
|
58
|
-
|
59
|
-
# returns the limits that imagemagick is running based on any "set_limits" calls
|
60
|
-
def get_current_limits(options = {})
|
61
|
-
mem_fix = 1
|
62
|
-
parse_limits(options.merge(:get_current_limits => true))
|
63
|
-
end
|
64
|
-
|
65
|
-
alias :get_limits :get_current_limits
|
66
|
-
|
67
|
-
def parse_limits(options)
|
68
|
-
show_actual_values = options[:show_actual_values]
|
69
|
-
if options[:get_current_limits]
|
70
|
-
raw_limits = self.raw_command('identify', '-list resource')
|
71
|
-
else
|
72
|
-
# we run a raw shell command here to obtain limits without applying command line limit params
|
73
|
-
raw_limits = `identify -list resource`
|
74
|
-
end
|
75
|
-
actual_values, readable_values = parser.parse_limits(raw_limits)
|
76
|
-
show_actual_values ? actual_values : readable_values
|
77
|
-
end # parse_limits
|
78
|
-
|
79
|
-
# returns a string suitable for passing as a set of imagemagick params
|
80
|
-
# that contains all the limit constraints
|
81
|
-
def get_limits_as_params
|
82
|
-
retval = ''
|
83
|
-
# we upcase the value here for newer versions of ImageMagick (>=6.8.x)
|
84
|
-
@@resource_limits.each do |type, value|
|
85
|
-
retval += " -limit #{type.to_s} #{value.upcase} "
|
86
|
-
end
|
87
|
-
retval
|
88
|
-
end
|
89
|
-
|
90
|
-
def parser
|
91
|
-
@parser ||= MojoMagick::Util::Parser.new
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|