mini_magick 3.8.1 → 4.0.0.rc

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.

Potentially problematic release.


This version of mini_magick might be problematic. Click here for more details.

Files changed (51) hide show
  1. checksums.yaml +4 -4
  2. data/lib/mini_gmagick.rb +2 -1
  3. data/lib/mini_magick.rb +43 -65
  4. data/lib/mini_magick/configuration.rb +136 -0
  5. data/lib/mini_magick/image.rb +356 -336
  6. data/lib/mini_magick/image/info.rb +104 -0
  7. data/lib/mini_magick/logger.rb +40 -0
  8. data/lib/mini_magick/shell.rb +46 -0
  9. data/lib/mini_magick/tool.rb +233 -0
  10. data/lib/mini_magick/tool/animate.rb +14 -0
  11. data/lib/mini_magick/tool/compare.rb +14 -0
  12. data/lib/mini_magick/tool/composite.rb +14 -0
  13. data/lib/mini_magick/tool/conjure.rb +14 -0
  14. data/lib/mini_magick/tool/convert.rb +14 -0
  15. data/lib/mini_magick/tool/display.rb +14 -0
  16. data/lib/mini_magick/tool/identify.rb +14 -0
  17. data/lib/mini_magick/tool/import.rb +14 -0
  18. data/lib/mini_magick/tool/mogrify.rb +14 -0
  19. data/lib/mini_magick/tool/montage.rb +14 -0
  20. data/lib/mini_magick/tool/stream.rb +14 -0
  21. data/lib/mini_magick/utilities.rb +23 -50
  22. data/lib/mini_magick/version.rb +6 -6
  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 +318 -410
  30. data/spec/lib/mini_magick/shell_spec.rb +66 -0
  31. data/spec/lib/mini_magick/tool_spec.rb +90 -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 +42 -76
  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
@@ -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
@@ -1 +0,0 @@
1
- <?php I am so not an image ?>
Binary file
Binary file
Binary file
Binary file
@@ -1,153 +0,0 @@
1
- require 'spec_helper'
2
-
3
- # All tests tagged as `ported` are ported from
4
- # testunit tests and are there for backwards compatibility
5
-
6
- MiniMagick.processor = :mogrify
7
-
8
- describe MiniMagick::CommandBuilder do
9
- before do
10
- @processor = MiniMagick.processor
11
- @processor_path = MiniMagick.processor_path
12
- end
13
-
14
- after do
15
- MiniMagick.processor_path = @processor_path
16
- MiniMagick.processor = @processor
17
- end
18
-
19
- describe 'ported from testunit', :ported => true do
20
- let(:builder) { described_class.new('test') }
21
-
22
- it 'builds a basic command' do
23
- builder.resize '30x40'
24
- expect(builder.args.join(' ')).to eq '-resize 30x40'
25
- end
26
-
27
- it 'builds a full command' do
28
- builder.resize '30x40'
29
- expect(builder.command).to eq 'test -resize 30x40'
30
- end
31
-
32
- describe 'windows only', :if => MiniMagick::Utilities.windows? do
33
- it 'builds a complicated command' do
34
- builder.resize '30x40'
35
- builder.alpha '1 3 4'
36
- builder.resize 'mome fingo'
37
- expect(builder.args.join(' ')).to eq '-resize 30x40 -alpha 1 3 4 -resize mome fingo'
38
- end
39
-
40
- it 'builds a command with multiple options and plus modifier' do
41
- builder.distort.+ 'srt', '0.6 20'
42
- expect(builder.args.join(' ')).to eq '+distort srt 0.6 20'
43
- end
44
-
45
- it 'sets a colorspace correctly' do
46
- builder.set 'colorspace RGB'
47
- expect(builder.command).to eq 'test -set colorspace RGB'
48
- end
49
- end
50
-
51
- describe 'not windows', :if => !MiniMagick::Utilities.windows? do
52
- it 'builds a complicated command' do
53
- builder.resize '30x40'
54
- builder.alpha '1 3 4'
55
- builder.resize 'mome fingo'
56
- expect(builder.args.join(' ')).to eq '-resize 30x40 -alpha 1\ 3\ 4 -resize mome\ fingo'
57
- end
58
-
59
- it 'sets a colorspace correctly' do
60
- builder.set 'colorspace RGB'
61
- expect(builder.command).to eq 'test -set colorspace\ RGB'
62
- end
63
-
64
- it 'builds a command with multiple options and plus modifier' do
65
- builder.distort.+ 'srt', '0.6 20'
66
- expect(builder.args.join(' ')).to eq '\+distort srt 0.6\ 20'
67
- end
68
- end
69
-
70
- describe 'common verbs between morgify and image creation operators' do
71
- context 'mogrify' do
72
- let(:builder) { described_class.new('mogrify') }
73
-
74
- it 'builds the command' do
75
- builder.caption 'caption_text'
76
- expect(builder.command).to eq 'mogrify -caption caption_text'
77
- end
78
- end
79
-
80
- context 'other' do
81
- it 'builds the command' do
82
- builder.caption 'caption_text'
83
- expect(builder.command).to eq 'test caption:caption_text'
84
- end
85
- end
86
- end
87
-
88
- it 'raises error when command is invalid' do
89
- expect {
90
- command = described_class.new('test', 'path')
91
- command.input 2
92
- }.to raise_error
93
- end
94
-
95
- it 'builds a dashed command' do
96
- builder.auto_orient
97
- expect(builder.args.join(' ')).to eq '-auto-orient'
98
- end
99
-
100
- it 'builds a dashed command via send' do
101
- builder.send('auto-orient')
102
- expect(builder.args.join(' ')).to eq '-auto-orient'
103
- end
104
-
105
- it 'builds a canvas command' do
106
- builder.canvas 'black'
107
- expect(builder.args.join(' ')).to eq 'canvas:black'
108
- end
109
-
110
- it 'sets a processor path correctly' do
111
- MiniMagick.processor_path = '/a/strange/path'
112
- builder.auto_orient
113
- expect(builder.command).to eq '/a/strange/path/test -auto-orient'
114
- end
115
-
116
- it 'builds a processor path with processor' do
117
- MiniMagick.processor_path = '/a/strange/path'
118
- MiniMagick.processor = 'processor'
119
- builder.auto_orient
120
- expect(builder.command).to eq '/a/strange/path/processor test -auto-orient'
121
- end
122
- end
123
-
124
- describe 'deprecated' do
125
- let(:builder) { described_class.new('test') }
126
- before { MiniMagick.processor = nil }
127
-
128
- it 'builds a full command' do
129
- builder.resize '30x40'
130
- expect(builder.command).to eq 'test -resize 30x40'
131
- end
132
-
133
- context 'windows only', :if => MiniMagick::Utilities.windows? do
134
- it 'sets a colorspace correctly' do
135
- builder.set 'colorspace RGB'
136
- expect(builder.command).to eq 'test -set colorspace RGB'
137
- end
138
- end
139
-
140
- context 'not windows', :if => !MiniMagick::Utilities.windows? do
141
- it 'sets a colorspace correctly' do
142
- builder.set 'colorspace RGB'
143
- expect(builder.command).to eq 'test -set colorspace\ RGB'
144
- end
145
- end
146
-
147
- it 'sets a processor path correctly' do
148
- MiniMagick.processor_path = '/a/strange/path'
149
- builder.auto_orient
150
- expect(builder.command).to eq '/a/strange/path/test -auto-orient'
151
- end
152
- end
153
- end