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.
- checksums.yaml +4 -4
- data/lib/mini_gmagick.rb +2 -1
- data/lib/mini_magick/configuration.rb +136 -0
- data/lib/mini_magick/image/info.rb +122 -0
- data/lib/mini_magick/image.rb +380 -334
- data/lib/mini_magick/logger.rb +40 -0
- data/lib/mini_magick/shell.rb +48 -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/mogrify.rb +14 -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 +250 -0
- data/lib/mini_magick/utilities.rb +23 -50
- data/lib/mini_magick/version.rb +5 -5
- data/lib/mini_magick.rb +43 -65
- data/spec/fixtures/animation.gif +0 -0
- data/spec/fixtures/default.jpg +0 -0
- data/spec/fixtures/exif.jpg +0 -0
- data/spec/fixtures/image.psd +0 -0
- data/spec/fixtures/not_an_image.rb +1 -0
- data/spec/lib/mini_magick/configuration_spec.rb +66 -0
- data/spec/lib/mini_magick/image_spec.rb +367 -406
- data/spec/lib/mini_magick/shell_spec.rb +66 -0
- data/spec/lib/mini_magick/tool_spec.rb +107 -0
- data/spec/lib/mini_magick/utilities_spec.rb +17 -0
- data/spec/lib/mini_magick_spec.rb +23 -47
- data/spec/spec_helper.rb +17 -25
- data/spec/support/helpers.rb +37 -0
- metadata +40 -74
- data/lib/mini_magick/command_builder.rb +0 -94
- data/lib/mini_magick/errors.rb +0 -4
- data/spec/files/actually_a_gif.jpg +0 -0
- data/spec/files/animation.gif +0 -0
- data/spec/files/composited.jpg +0 -0
- data/spec/files/erroneous.jpg +0 -0
- data/spec/files/layers.psd +0 -0
- data/spec/files/leaves (spaced).tiff +0 -0
- data/spec/files/not_an_image.php +0 -1
- data/spec/files/png.png +0 -0
- data/spec/files/simple-minus.gif +0 -0
- data/spec/files/simple.gif +0 -0
- data/spec/files/trogdor.jpg +0 -0
- data/spec/files/trogdor_capitalized.JPG +0 -0
- data/spec/lib/mini_magick/command_builder_spec.rb +0 -153
data/lib/mini_magick.rb
CHANGED
|
@@ -1,75 +1,53 @@
|
|
|
1
|
-
require 'mini_magick/
|
|
2
|
-
require 'mini_magick/
|
|
1
|
+
require 'mini_magick/configuration'
|
|
2
|
+
require 'mini_magick/tool'
|
|
3
3
|
require 'mini_magick/image'
|
|
4
|
-
require 'mini_magick/utilities'
|
|
5
4
|
|
|
6
5
|
module MiniMagick
|
|
7
|
-
@validate_on_create = true
|
|
8
|
-
@validate_on_write = true
|
|
9
6
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
end
|
|
28
|
-
end
|
|
7
|
+
extend MiniMagick::Configuration
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# You might want to execute only certain blocks of processing with a
|
|
11
|
+
# different CLI, because for example that CLI does that particular thing
|
|
12
|
+
# faster. After the block CLI resets to its previous value.
|
|
13
|
+
#
|
|
14
|
+
# @example
|
|
15
|
+
# MiniMagick.with_cli :graphicsmagick do
|
|
16
|
+
# # operations that are better done with GraphicsMagick
|
|
17
|
+
# end
|
|
18
|
+
def self.with_cli(cli)
|
|
19
|
+
old_cli = self.cli
|
|
20
|
+
self.cli = cli
|
|
21
|
+
yield
|
|
22
|
+
self.cli = old_cli
|
|
23
|
+
end
|
|
29
24
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
25
|
+
##
|
|
26
|
+
# Checks whether the CLI used is ImageMagick.
|
|
27
|
+
#
|
|
28
|
+
# @return [Boolean]
|
|
29
|
+
def self.imagemagick?
|
|
30
|
+
cli == :imagemagick
|
|
31
|
+
end
|
|
38
32
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
end
|
|
33
|
+
##
|
|
34
|
+
# Checks whether the CLI used is GraphicsMagick.
|
|
35
|
+
#
|
|
36
|
+
# @return [Boolean]
|
|
37
|
+
def self.graphicsmagick?
|
|
38
|
+
cli == :graphicsmagick
|
|
39
|
+
end
|
|
47
40
|
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
41
|
+
##
|
|
42
|
+
# Returns ImageMagick's/GraphicsMagick's version.
|
|
43
|
+
#
|
|
44
|
+
# @return [String]
|
|
45
|
+
def self.cli_version
|
|
46
|
+
output = MiniMagick::Tool::Identify.new(&:version)
|
|
47
|
+
output[/\d+\.\d+\.\d+(-\d+)?/]
|
|
48
|
+
end
|
|
56
49
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
#
|
|
60
|
-
# === Returns
|
|
61
|
-
# * [Boolean]
|
|
62
|
-
def mogrify?
|
|
63
|
-
processor && processor.to_sym == :mogrify
|
|
64
|
-
end
|
|
50
|
+
class Error < RuntimeError; end
|
|
51
|
+
class Invalid < StandardError; end
|
|
65
52
|
|
|
66
|
-
##
|
|
67
|
-
# Checks whether the current processor is graphicsmagick.
|
|
68
|
-
#
|
|
69
|
-
# === Returns
|
|
70
|
-
# * [Boolean]
|
|
71
|
-
def gm?
|
|
72
|
-
processor && processor.to_sym == :gm
|
|
73
|
-
end
|
|
74
|
-
end
|
|
75
53
|
end
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
expect(__FILE__).not_to be_an_image
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe MiniMagick::Configuration do
|
|
4
|
+
subject { Object.new.extend(MiniMagick::Configuration) }
|
|
5
|
+
|
|
6
|
+
describe "#configure" do
|
|
7
|
+
it "yields self" do
|
|
8
|
+
expect { |b| subject.configure(&b) }
|
|
9
|
+
.to yield_with_args(subject)
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
describe "#cli" do
|
|
14
|
+
it "can be assigned" do
|
|
15
|
+
subject.cli = :imagemagick
|
|
16
|
+
expect(subject.cli).to eq :imagemagick
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
it "returns :imagemagick if #processor is mogrify" do
|
|
20
|
+
allow(subject).to receive(:processor).and_return("mogrify")
|
|
21
|
+
expect(subject.cli).to eq :imagemagick
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it "returns :graphicsmagick if #processor is gm" do
|
|
25
|
+
allow(subject).to receive(:processor).and_return("gm")
|
|
26
|
+
expect(subject.cli).to eq :graphicsmagick
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it "returns nil of #processor is nil" do
|
|
30
|
+
allow(subject).to receive(:processor).and_return(nil)
|
|
31
|
+
expect(subject.cli).to eq nil
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
describe "#cli=" do
|
|
36
|
+
it "raises an error when set to an invalid value" do
|
|
37
|
+
expect { subject.cli = :grapicsmagick }
|
|
38
|
+
.to raise_error(ArgumentError)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
describe "#processor" do
|
|
43
|
+
it "assigns :mogrify by default" do
|
|
44
|
+
expect(subject.processor).to eq "mogrify"
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it "assigns :gm if ImageMagick is not available" do
|
|
48
|
+
allow(MiniMagick::Utilities).to receive(:which).with("mogrify").and_return(nil)
|
|
49
|
+
allow(MiniMagick::Utilities).to receive(:which).with("gm").and_return(true)
|
|
50
|
+
expect(subject.processor).to eq "gm"
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
it "returns nil if neither ImageMagick nor GraphicsMagick are available" do
|
|
54
|
+
allow(MiniMagick::Utilities).to receive(:which).with("mogrify").and_return(nil)
|
|
55
|
+
allow(MiniMagick::Utilities).to receive(:which).with("gm").and_return(nil)
|
|
56
|
+
expect(subject.processor).to eq nil
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
describe "#processor=" do
|
|
61
|
+
it "raises an error when set to an invalid value" do
|
|
62
|
+
expect { subject.processor = "mogrfy" }
|
|
63
|
+
.to raise_error(ArgumentError)
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|