mini_magick 3.8.1 → 4.0.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.
Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mini_gmagick.rb +2 -1
  3. data/lib/mini_magick/configuration.rb +136 -0
  4. data/lib/mini_magick/image/info.rb +122 -0
  5. data/lib/mini_magick/image.rb +380 -334
  6. data/lib/mini_magick/logger.rb +40 -0
  7. data/lib/mini_magick/shell.rb +48 -0
  8. data/lib/mini_magick/tool/animate.rb +14 -0
  9. data/lib/mini_magick/tool/compare.rb +14 -0
  10. data/lib/mini_magick/tool/composite.rb +14 -0
  11. data/lib/mini_magick/tool/conjure.rb +14 -0
  12. data/lib/mini_magick/tool/convert.rb +14 -0
  13. data/lib/mini_magick/tool/display.rb +14 -0
  14. data/lib/mini_magick/tool/identify.rb +14 -0
  15. data/lib/mini_magick/tool/import.rb +14 -0
  16. data/lib/mini_magick/tool/mogrify.rb +14 -0
  17. data/lib/mini_magick/tool/montage.rb +14 -0
  18. data/lib/mini_magick/tool/stream.rb +14 -0
  19. data/lib/mini_magick/tool.rb +250 -0
  20. data/lib/mini_magick/utilities.rb +23 -50
  21. data/lib/mini_magick/version.rb +5 -5
  22. data/lib/mini_magick.rb +43 -65
  23. data/spec/fixtures/animation.gif +0 -0
  24. data/spec/fixtures/default.jpg +0 -0
  25. data/spec/fixtures/exif.jpg +0 -0
  26. data/spec/fixtures/image.psd +0 -0
  27. data/spec/fixtures/not_an_image.rb +1 -0
  28. data/spec/lib/mini_magick/configuration_spec.rb +66 -0
  29. data/spec/lib/mini_magick/image_spec.rb +367 -406
  30. data/spec/lib/mini_magick/shell_spec.rb +66 -0
  31. data/spec/lib/mini_magick/tool_spec.rb +107 -0
  32. data/spec/lib/mini_magick/utilities_spec.rb +17 -0
  33. data/spec/lib/mini_magick_spec.rb +23 -47
  34. data/spec/spec_helper.rb +17 -25
  35. data/spec/support/helpers.rb +37 -0
  36. metadata +40 -74
  37. data/lib/mini_magick/command_builder.rb +0 -94
  38. data/lib/mini_magick/errors.rb +0 -4
  39. data/spec/files/actually_a_gif.jpg +0 -0
  40. data/spec/files/animation.gif +0 -0
  41. data/spec/files/composited.jpg +0 -0
  42. data/spec/files/erroneous.jpg +0 -0
  43. data/spec/files/layers.psd +0 -0
  44. data/spec/files/leaves (spaced).tiff +0 -0
  45. data/spec/files/not_an_image.php +0 -1
  46. data/spec/files/png.png +0 -0
  47. data/spec/files/simple-minus.gif +0 -0
  48. data/spec/files/simple.gif +0 -0
  49. data/spec/files/trogdor.jpg +0 -0
  50. data/spec/files/trogdor_capitalized.JPG +0 -0
  51. data/spec/lib/mini_magick/command_builder_spec.rb +0 -153
@@ -0,0 +1,66 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe MiniMagick::Shell do
4
+ subject { described_class.new }
5
+
6
+ describe "#run" do
7
+ it "calls #execute with the command" do
8
+ expect(subject).to receive(:execute).and_call_original
9
+ subject.run(%W[identify #{image_path}])
10
+ end
11
+
12
+ it "returns stdout" do
13
+ allow(subject).to receive(:execute).and_return(["stdout", "stderr", 0])
14
+ output = subject.run(%W[foo])
15
+ expect(output).to eq "stdout"
16
+ end
17
+
18
+ it "uses stderr for error messages" do
19
+ allow(subject).to receive(:execute).and_return(["", "stderr", 1])
20
+ expect { subject.run(%W[foo]) }
21
+ .to raise_error(MiniMagick::Error, /`foo`.*stderr/m)
22
+ end
23
+
24
+ it "raises an error when executable wasn't found" do
25
+ allow(subject).to receive(:execute).and_return(["", "not found", 127])
26
+ expect { subject.run(%W[foo]) }
27
+ .to raise_error(MiniMagick::Error, /not found/)
28
+ end
29
+
30
+ it "raises errors only in whiny mode" do
31
+ subject = described_class.new(false)
32
+ allow(subject).to receive(:execute).and_return(["stdout", "", 127])
33
+ expect(subject.run(%W[foo])).to eq "stdout"
34
+ end
35
+
36
+ it "prints to stderr output to $stderr in non-whiny mode" do
37
+ subject = described_class.new(false)
38
+ allow(subject).to receive(:execute).and_return(["", "stderr", 1])
39
+ expect { subject.run(%W[foo]) }.to output("stderr").to_stderr
40
+ end
41
+ end
42
+
43
+ describe "#execute" do
44
+ it "executes the command in the shell" do
45
+ stdout, * = subject.execute(%W[identify #{image_path(:gif)}])
46
+ expect(stdout).to match("GIF")
47
+ end
48
+
49
+ it "logs the command and execution time in debug mode" do
50
+ allow(MiniMagick).to receive(:debug).and_return(true)
51
+ expect { subject.execute(%W[identify #{image_path(:gif)}]) }.
52
+ to output(/\[\d+.\d+s\] identify #{image_path(:gif)}/).to_stdout
53
+ end
54
+
55
+ it "returns an appropriate response when command wasn't found" do
56
+ stdout, stderr, code = subject.execute(%W[unexisting command])
57
+ expect(code).to eq 127
58
+ expect(stderr).to match(/not found/)
59
+ end
60
+
61
+ it "doesn't break on spaces" do
62
+ stdout, * = subject.execute(["identify", "-format", "%w %h", image_path])
63
+ expect(stdout).to match(/\d+ \d+/)
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,107 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe MiniMagick::Tool do
4
+ subject { MiniMagick::Tool::Identify.new }
5
+
6
+ describe "#call" do
7
+ it "calls the shell to run the command" do
8
+ subject << image_path(:gif)
9
+ output = subject.call
10
+ expect(output).to match("GIF")
11
+ end
12
+
13
+ it "strips the output" do
14
+ subject << image_path
15
+ output = subject.call
16
+ expect(output).not_to end_with("\n")
17
+ end
18
+ end
19
+
20
+ describe ".new" do
21
+ it "accepts a block, and immediately executes the command" do
22
+ output = described_class.new("identify") do |builder|
23
+ builder << image_path(:gif)
24
+ end
25
+ expect(output).to match("GIF")
26
+ end
27
+ end
28
+
29
+ describe "#command" do
30
+ it "includes the executable and the arguments" do
31
+ allow(subject).to receive(:args).and_return(%W[-list Command])
32
+ expect(subject.command).to include(*%W[identify -list Command])
33
+ end
34
+ end
35
+
36
+ describe "#executable" do
37
+ it "prepends 'gm' to the command list when using GraphicsMagick" do
38
+ allow(MiniMagick).to receive(:cli).and_return(:graphicsmagick)
39
+ expect(subject.executable).to eq %W[gm identify]
40
+ end
41
+
42
+ it "respects #cli_path" do
43
+ allow(MiniMagick).to receive(:cli).and_return(:imagemagick)
44
+ allow(MiniMagick).to receive(:cli_path).and_return("path/to/cli")
45
+ expect(subject.executable).to eq %W[path/to/cli/identify]
46
+ end
47
+ end
48
+
49
+ describe "#<<" do
50
+ it "adds argument to the args list" do
51
+ subject << "foo" << "bar" << 123
52
+ expect(subject.args).to eq %W[foo bar 123]
53
+ end
54
+ end
55
+
56
+ describe "#merge!" do
57
+ it "adds arguments to the args list" do
58
+ subject << "pre-existing"
59
+ subject.merge! ["foo", 123]
60
+ expect(subject.args).to eq %W[pre-existing foo 123]
61
+ end
62
+ end
63
+
64
+ describe "#+" do
65
+ it "switches the last option to + form" do
66
+ subject.help
67
+ subject.help.+
68
+ subject.debug.+ "foo"
69
+ subject.debug.+ 8, "bar"
70
+ expect(subject.args).to eq %W[-help +help +debug foo +debug 8 bar]
71
+ end
72
+ end
73
+
74
+ ["ImageMagick", "GraphicsMagick"].each do |cli|
75
+ context "with #{cli}", cli: cli.downcase.to_sym do
76
+ it "adds dynamically generated operator methods" do
77
+ subject.help.depth(8)
78
+ expect(subject.args).to eq %W[-help -depth 8]
79
+ end
80
+
81
+ it "doesn't just delegate to #method_missing" do
82
+ expect(subject.class.instance_methods).to include(:help)
83
+ end
84
+
85
+ it "adds dynamically generated creation operator methods" do
86
+ subject.radial_gradient.canvas "khaki"
87
+ expect(subject.args).to eq %W[radial-gradient: canvas:khaki]
88
+ end
89
+ end
90
+ end
91
+
92
+ it "resets the dynamically generated operator methods on CLI change" do
93
+ MiniMagick.cli = :imagemagick
94
+ expect(subject).to respond_to(:quiet)
95
+
96
+ MiniMagick.cli = :graphicsmagick
97
+ expect(subject).not_to respond_to(:quiet)
98
+ expect(subject).to respond_to(:ping)
99
+ end
100
+
101
+ it "doesn't raise errors when false is passed to the constructor" do
102
+ subject.help
103
+ subject.call(false)
104
+
105
+ MiniMagick::Tool::Identify.new(false, &:help)
106
+ end
107
+ end
@@ -0,0 +1,17 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe MiniMagick::Utilities do
4
+ describe ".which" do
5
+ it "identifies when mogrify exists" do
6
+ expect(MiniMagick::Utilities.which('mogrify')).not_to be_nil
7
+ end
8
+
9
+ it "identifies when gm exists" do
10
+ expect(MiniMagick::Utilities.which('gm')).not_to be_nil
11
+ end
12
+
13
+ it "returns nil on nonexistent executables" do
14
+ expect(MiniMagick::Utilities.which('yogrify')).to be_nil
15
+ end
16
+ end
17
+ end
@@ -1,63 +1,39 @@
1
- require 'spec_helper'
1
+ require "spec_helper"
2
2
 
3
- describe MiniMagick do
4
- context 'which util' do
5
- it 'identifies when mogrify exists' do
6
- expect(MiniMagick::Utilities.which('mogrify')).not_to be_nil
3
+ RSpec.describe MiniMagick do
4
+ describe ".imagemagick?" do
5
+ it "returns true if CLI is minimagick" do
6
+ allow(described_class).to receive(:cli).and_return(:imagemagick)
7
+ expect(described_class.imagemagick?).to eq true
7
8
  end
8
9
 
9
- it 'identifies when gm exists' do
10
- expect(MiniMagick::Utilities.which('gm')).not_to be_nil
11
- end
12
-
13
- it 'returns nil on nonexistent executables' do
14
- expect(MiniMagick::Utilities.which('yogrify')).to be_nil
10
+ it "returns false if CLI isn't minimagick" do
11
+ allow(described_class).to receive(:cli).and_return(:graphicsmagick)
12
+ expect(described_class.imagemagick?).to eq false
15
13
  end
16
14
  end
17
15
 
18
- context '.mogrify?' do
19
- it 'returns true if minimagick is using mogrify' do
20
- described_class.processor = :mogrify
21
- expect(described_class.mogrify?).to eq true
22
- end
23
-
24
- it 'returns false if minimagick is not using mogrify' do
25
- described_class.processor = :gm
26
- expect(described_class.mogrify?).to eq false
27
- end
28
-
29
- it 'sets the processor if not set' do
30
- described_class.processor = nil
31
- described_class.mogrify?
32
- expect(described_class.processor).to eq :mogrify
33
- end
34
- end
35
-
36
- context '.gm?' do
37
- it 'returns true if minimagick is using gm' do
38
- described_class.processor = :gm
39
- expect(described_class).to be_gm
40
- end
41
-
42
- it 'returns false if minimagick is not using gm' do
43
- described_class.processor = :mogrify
44
- expect(described_class).not_to be_gm
16
+ describe ".graphicsmagick?" do
17
+ it "returns true if CLI is graphicsmagick" do
18
+ allow(described_class).to receive(:cli).and_return(:graphicsmagick)
19
+ expect(described_class.graphicsmagick?).to eq true
45
20
  end
46
21
 
47
- it 'sets the processor if not set' do
48
- described_class.processor = nil
49
- described_class.gm?
50
- expect(described_class.processor).to eq :mogrify
22
+ it "returns false if CLI isn't graphicsmagick" do
23
+ allow(described_class).to receive(:cli).and_return(:imagemagick)
24
+ expect(described_class.graphicsmagick?).to eq false
51
25
  end
52
26
  end
53
27
 
54
- context 'validation' do
55
- it 'validates on create' do
56
- expect(MiniMagick.validate_on_create).to eq(true)
28
+ describe ".cli_version" do
29
+ it "returns ImageMagick's version" do
30
+ allow(described_class).to receive(:cli).and_return(:imagemagick)
31
+ expect(described_class.cli_version).to match(/^\d+\.\d+\.\d+-\d+$/)
57
32
  end
58
33
 
59
- it 'validates on write' do
60
- expect(MiniMagick.validate_on_write).to eq(true)
34
+ it "returns GraphicsMagick's version" do
35
+ allow(described_class).to receive(:cli).and_return(:graphicsmagick)
36
+ expect(described_class.cli_version).to match(/^\d+\.\d+\.\d+$/)
61
37
  end
62
38
  end
63
39
  end
data/spec/spec_helper.rb CHANGED
@@ -1,29 +1,21 @@
1
- require 'rubygems'
2
- require 'bundler/setup'
3
- require 'rspec'
4
- require 'mocha/api'
1
+ require "bundler/setup"
2
+ require "mini_magick"
3
+ require "pry"
5
4
 
6
- require 'mini_magick'
5
+ require_relative "support/helpers"
7
6
 
8
7
  RSpec.configure do |config|
9
- config.mock_framework = :mocha
10
- config.color = true
11
- config.formatter = 'documentation'
12
- config.raise_errors_for_deprecations!
13
- end
8
+ config.disable_monkey_patching!
9
+ config.formatter = "documentation"
10
+ config.color = true
11
+ config.fail_fast = true unless ENV["CI"]
14
12
 
15
- # Image files from testunit port to RSpec
16
- test_files = File.expand_path(File.dirname(__FILE__) + '/files')
17
- TEST_FILES_PATH = test_files
18
- SIMPLE_IMAGE_PATH = test_files + '/simple.gif'
19
- MINUS_IMAGE_PATH = test_files + '/simple-minus.gif'
20
- TIFF_IMAGE_PATH = test_files + '/leaves (spaced).tiff'
21
- NOT_AN_IMAGE_PATH = test_files + '/not_an_image.php'
22
- GIF_WITH_JPG_EXT = test_files + '/actually_a_gif.jpg'
23
- EXIF_IMAGE_PATH = test_files + '/trogdor.jpg'
24
- CAP_EXT_PATH = test_files + '/trogdor_capitalized.JPG'
25
- ANIMATION_PATH = test_files + '/animation.gif'
26
- PNG_PATH = test_files + '/png.png'
27
- COMP_IMAGE_PATH = test_files + '/composited.jpg'
28
- ERRONEOUS_IMAGE_PATH = test_files + '/erroneous.jpg'
29
- PSD_IMAGE_PATH = test_files + '/layers.psd'
13
+ [:imagemagick, :graphicsmagick].each do |cli|
14
+ config.around(cli: cli) do |example|
15
+ MiniMagick.with_cli(cli) { example.run }
16
+ end
17
+ config.around(skip_cli: cli) do |example|
18
+ example.run unless example.metadata[:cli] == cli
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,37 @@
1
+ require "tempfile"
2
+
3
+ module Helpers
4
+ def image_path(type = :default)
5
+ if type != :without_extension
6
+ File.join("spec/fixtures",
7
+ case type
8
+ when :default, :jpg then "default.jpg"
9
+ when :animation, :gif then "animation.gif"
10
+ when :pdf then "document.pdf"
11
+ when :psd then "image.psd"
12
+ when :exif then "exif.jpg"
13
+ when :not then "not_an_image.rb"
14
+ else
15
+ fail "image #{type.inspect} doesn't exist"
16
+ end
17
+ )
18
+ else
19
+ path = random_path
20
+ FileUtils.cp image_path, path
21
+ path
22
+ end
23
+ end
24
+
25
+ def image_url
26
+ "https://avatars2.githubusercontent.com/u/795488?v=2&s=40"
27
+ end
28
+
29
+ def random_path(basename = "")
30
+ @tempfile = Tempfile.open(basename)
31
+ @tempfile.path
32
+ end
33
+ end
34
+
35
+ RSpec.configure do |config|
36
+ config.include Helpers
37
+ 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: 3.8.1
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Johnson
@@ -12,22 +12,8 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2014-09-11 00:00:00.000000000 Z
15
+ date: 2014-11-14 00:00:00.000000000 Z
16
16
  dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: subexec
19
- requirement: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - "~>"
22
- - !ruby/object:Gem::Version
23
- version: 0.2.1
24
- type: :runtime
25
- prerelease: false
26
- version_requirements: !ruby/object:Gem::Requirement
27
- requirements:
28
- - - "~>"
29
- - !ruby/object:Gem::Version
30
- version: 0.2.1
31
17
  - !ruby/object:Gem::Dependency
32
18
  name: rake
33
19
  requirement: !ruby/object:Gem::Requirement
@@ -42,48 +28,20 @@ dependencies:
42
28
  - - ">="
43
29
  - !ruby/object:Gem::Version
44
30
  version: '0'
45
- - !ruby/object:Gem::Dependency
46
- name: test-unit
47
- requirement: !ruby/object:Gem::Requirement
48
- requirements:
49
- - - ">="
50
- - !ruby/object:Gem::Version
51
- version: '0'
52
- type: :development
53
- prerelease: false
54
- version_requirements: !ruby/object:Gem::Requirement
55
- requirements:
56
- - - ">="
57
- - !ruby/object:Gem::Version
58
- version: '0'
59
31
  - !ruby/object:Gem::Dependency
60
32
  name: rspec
61
33
  requirement: !ruby/object:Gem::Requirement
62
34
  requirements:
63
35
  - - "~>"
64
36
  - !ruby/object:Gem::Version
65
- version: 3.0.0
37
+ version: 3.1.0
66
38
  type: :development
67
39
  prerelease: false
68
40
  version_requirements: !ruby/object:Gem::Requirement
69
41
  requirements:
70
42
  - - "~>"
71
43
  - !ruby/object:Gem::Version
72
- version: 3.0.0
73
- - !ruby/object:Gem::Dependency
74
- name: mocha
75
- requirement: !ruby/object:Gem::Requirement
76
- requirements:
77
- - - ">="
78
- - !ruby/object:Gem::Version
79
- version: '0'
80
- type: :development
81
- prerelease: false
82
- version_requirements: !ruby/object:Gem::Requirement
83
- requirements:
84
- - - ">="
85
- - !ruby/object:Gem::Version
86
- version: '0'
44
+ version: 3.1.0
87
45
  description: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
88
46
  email:
89
47
  - probablycorey@gmail.com
@@ -99,27 +57,38 @@ files:
99
57
  - Rakefile
100
58
  - lib/mini_gmagick.rb
101
59
  - lib/mini_magick.rb
102
- - lib/mini_magick/command_builder.rb
103
- - lib/mini_magick/errors.rb
60
+ - lib/mini_magick/configuration.rb
104
61
  - lib/mini_magick/image.rb
62
+ - lib/mini_magick/image/info.rb
63
+ - lib/mini_magick/logger.rb
64
+ - lib/mini_magick/shell.rb
65
+ - lib/mini_magick/tool.rb
66
+ - lib/mini_magick/tool/animate.rb
67
+ - lib/mini_magick/tool/compare.rb
68
+ - lib/mini_magick/tool/composite.rb
69
+ - lib/mini_magick/tool/conjure.rb
70
+ - lib/mini_magick/tool/convert.rb
71
+ - lib/mini_magick/tool/display.rb
72
+ - lib/mini_magick/tool/identify.rb
73
+ - lib/mini_magick/tool/import.rb
74
+ - lib/mini_magick/tool/mogrify.rb
75
+ - lib/mini_magick/tool/montage.rb
76
+ - lib/mini_magick/tool/stream.rb
105
77
  - lib/mini_magick/utilities.rb
106
78
  - lib/mini_magick/version.rb
107
- - spec/files/actually_a_gif.jpg
108
- - spec/files/animation.gif
109
- - spec/files/composited.jpg
110
- - spec/files/erroneous.jpg
111
- - spec/files/layers.psd
112
- - spec/files/leaves (spaced).tiff
113
- - spec/files/not_an_image.php
114
- - spec/files/png.png
115
- - spec/files/simple-minus.gif
116
- - spec/files/simple.gif
117
- - spec/files/trogdor.jpg
118
- - spec/files/trogdor_capitalized.JPG
119
- - spec/lib/mini_magick/command_builder_spec.rb
79
+ - spec/fixtures/animation.gif
80
+ - spec/fixtures/default.jpg
81
+ - spec/fixtures/exif.jpg
82
+ - spec/fixtures/image.psd
83
+ - spec/fixtures/not_an_image.rb
84
+ - spec/lib/mini_magick/configuration_spec.rb
120
85
  - spec/lib/mini_magick/image_spec.rb
86
+ - spec/lib/mini_magick/shell_spec.rb
87
+ - spec/lib/mini_magick/tool_spec.rb
88
+ - spec/lib/mini_magick/utilities_spec.rb
121
89
  - spec/lib/mini_magick_spec.rb
122
90
  - spec/spec_helper.rb
91
+ - spec/support/helpers.rb
123
92
  homepage: https://github.com/minimagick/minimagick
124
93
  licenses:
125
94
  - MIT
@@ -146,19 +115,16 @@ signing_key:
146
115
  specification_version: 4
147
116
  summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
148
117
  test_files:
149
- - spec/files/actually_a_gif.jpg
150
- - spec/files/animation.gif
151
- - spec/files/composited.jpg
152
- - spec/files/erroneous.jpg
153
- - spec/files/layers.psd
154
- - spec/files/leaves (spaced).tiff
155
- - spec/files/not_an_image.php
156
- - spec/files/png.png
157
- - spec/files/simple-minus.gif
158
- - spec/files/simple.gif
159
- - spec/files/trogdor.jpg
160
- - spec/files/trogdor_capitalized.JPG
161
- - spec/lib/mini_magick/command_builder_spec.rb
118
+ - spec/fixtures/animation.gif
119
+ - spec/fixtures/default.jpg
120
+ - spec/fixtures/exif.jpg
121
+ - spec/fixtures/image.psd
122
+ - spec/fixtures/not_an_image.rb
123
+ - spec/lib/mini_magick/configuration_spec.rb
162
124
  - spec/lib/mini_magick/image_spec.rb
125
+ - spec/lib/mini_magick/shell_spec.rb
126
+ - spec/lib/mini_magick/tool_spec.rb
127
+ - spec/lib/mini_magick/utilities_spec.rb
163
128
  - spec/lib/mini_magick_spec.rb
164
129
  - spec/spec_helper.rb
130
+ - spec/support/helpers.rb
@@ -1,94 +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 if MiniMagick.processor_path
17
- com.strip
18
- end
19
-
20
- def args
21
- @args.map { |arg| Utilities.escape(arg) }
22
- end
23
-
24
- # Add each mogrify command in both underscore and dash format
25
- MOGRIFY_COMMANDS.each do |mogrify_command|
26
-
27
- # Example of what is generated here:
28
- #
29
- # def auto_orient(*options)
30
- # add_command("auto-orient", *options)
31
- # self
32
- # end
33
- # alias_method :"auto-orient", :auto_orient
34
-
35
- dashed_command = mogrify_command.to_s.gsub('_', '-')
36
- underscored_command = mogrify_command.to_s.gsub('-', '_')
37
-
38
- define_method(underscored_command) do |*options|
39
- options[1] = Utilities.windows_escape(options[1]) if mogrify_command == 'annotate'
40
- add_command(__method__.to_s.gsub('_', '-'), *options)
41
- self
42
- end
43
-
44
- alias_method dashed_command, underscored_command
45
- alias_method "mogrify_#{underscored_command}", underscored_command
46
- end
47
-
48
- def format(*options)
49
- fail Error, "You must call 'format' on the image object directly!"
50
- end
51
-
52
- IMAGE_CREATION_OPERATORS.each do |operator|
53
- define_method operator do |*options|
54
- add_creation_operator(__method__.to_s, *options)
55
- self
56
- end
57
-
58
- alias_method "operator_#{operator}", operator
59
- end
60
-
61
- (MOGRIFY_COMMANDS & IMAGE_CREATION_OPERATORS).each do |command_or_operator|
62
- define_method command_or_operator do |*options|
63
- if @tool == 'mogrify'
64
- method = self.method("mogrify_#{command_or_operator}")
65
- else
66
- method = self.method("operator_#{command_or_operator}")
67
- end
68
- method.call(*options)
69
- end
70
-
71
- end
72
-
73
- def +(*options)
74
- push(@args.pop.gsub(/\A-/, '+'))
75
- options.to_a.each { |option| push(option) }
76
- end
77
-
78
- def add_command(command, *options)
79
- push "-#{command}"
80
- options.to_a.each { |option| push(option) }
81
- end
82
-
83
- def add_creation_operator(command, *options)
84
- creation_command = command
85
- options.to_a.each { |option| creation_command << ":#{option}" }
86
- push creation_command
87
- end
88
-
89
- def push(arg)
90
- @args << arg.to_s.strip
91
- end
92
- alias_method :<<, :push
93
- end
94
- end
@@ -1,4 +0,0 @@
1
- module MiniMagick
2
- class Error < RuntimeError; end
3
- class Invalid < StandardError; end
4
- end
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1 +0,0 @@
1
- <?php I am so not an image ?>
data/spec/files/png.png DELETED
Binary file
Binary file
Binary file
Binary file
Binary file