graphicsmagick 1.0.5 → 1.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/.gitignore +2 -0
- data/lib/graphicsmagick/image.rb +61 -56
- data/lib/graphicsmagick/version.rb +1 -1
- metadata +8 -9
- data/lib/graphicsmagick/.DS_Store +0 -0
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
YWRhMDc1MTUyZjcyNWIyNmNhMjQ5MGY0YTBjY2RjMWExZDU4MTYwZg==
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3ab21c37d819c49def5a8aa98a3ed90a6ab0f1f6717fac438d8250f06f604d99
|
4
|
+
data.tar.gz: 219be75aa7b43b7fdd644418de9b0deff2cc56c276d4439f0333c021b09f6c81
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
NmMxMzRmMmUzNTdhM2Q0NTYwMzI2ZGJiNjU2NTY3YzZjN2FmNmUyMzNkZTdl
|
11
|
-
Mzg5MWI2OTI0MzJlZGYxNmY1M2Y3NDRmZDc3YThlNTlhMjEwYzc=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
ZWQzMmNiMGI5MGI2NTI5OTcxYTU5MDdmYzQ0OGZlOTNkZDVjZGE5MTAwYzgw
|
14
|
-
MWMyMWU2MmQ4ZGE1NDFiYjQxMWFmZDgzY2UzZjk0ODkzYWY1YTNjMmRiNGZm
|
15
|
-
OGFkYmYwMDlkNDFiMjE3ZTg5NDU1NGQwZjQxOTNmZGNmMDQ0ZDg=
|
6
|
+
metadata.gz: 8273a3e318dd6fcb3f7f88e659761aac43e26f19e4b63cb3fc51946060d8718de6558e24e8cd38a60bab16dee5e713ef1c8980dc5f576a27355270c8a8ff20ae
|
7
|
+
data.tar.gz: 3197104fe4949341eb052db6ad55712aac15aea7abad7dc6c0046bc596bddcb8c0bf02793e2fc3e6d5bf87cd80f560a2e07cce3c8d91a047b1c6cada0cfa6aa6
|
data/.gitignore
CHANGED
data/lib/graphicsmagick/image.rb
CHANGED
@@ -2,87 +2,92 @@ require 'tempfile'
|
|
2
2
|
require 'subexec'
|
3
3
|
require 'shellwords'
|
4
4
|
require 'graphicsmagick/utilities'
|
5
|
-
require 'active_support/core_ext/numeric/time'
|
6
5
|
|
7
6
|
module GraphicsMagick
|
7
|
+
UnknownOptionError = Class.new(StandardError)
|
8
8
|
|
9
|
-
|
9
|
+
class Image
|
10
|
+
attr_reader :file
|
10
11
|
|
11
|
-
|
12
|
-
attr_reader :file
|
13
|
-
|
14
|
-
include GraphicsMagick::Utilities
|
12
|
+
include GraphicsMagick::Utilities
|
15
13
|
|
16
14
|
def initialize(input)
|
17
|
-
|
18
|
-
|
15
|
+
@command_options = []
|
16
|
+
@utility = nil
|
19
17
|
|
20
|
-
|
21
|
-
|
18
|
+
@file = parse_input(input)
|
19
|
+
end
|
22
20
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
21
|
+
# Returns the path of the associated file
|
22
|
+
def path
|
23
|
+
@file.path
|
24
|
+
end
|
27
25
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
26
|
+
# Writes the changes to the file specified in +output+.
|
27
|
+
# Set +:timeout => 30.seconds+ to change the timeout value.
|
28
|
+
# Default is one minute.
|
29
|
+
def write(output, opts = {})
|
30
|
+
output_path = parse_input(output, false)
|
32
31
|
|
33
|
-
|
34
|
-
|
35
|
-
command = build_command(output_path)
|
36
|
-
run(command, opts)
|
37
|
-
GraphicsMagick::Image.new(output_path)
|
38
|
-
end
|
32
|
+
FileUtils.copy_file(path, output_path) unless requires_output_file?
|
39
33
|
|
34
|
+
command = build_command(output_path)
|
35
|
+
run(command, opts)
|
36
|
+
GraphicsMagick::Image.new(output_path)
|
37
|
+
end
|
40
38
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
39
|
+
# Writes the changes to the current file.
|
40
|
+
# Set +:timeout => 30.seconds+ to change the timeout value.
|
41
|
+
# Default is one minute.
|
42
|
+
def write!(opts = {})
|
43
|
+
if requires_output_file?
|
44
|
+
raise NoMethodError, "You cannot use Image#write(output) with "\
|
45
|
+
"the #{current_utility} command"
|
46
|
+
end
|
45
47
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
48
|
+
command = build_command(path)
|
49
|
+
run(command, opts)
|
50
|
+
self
|
51
|
+
end
|
50
52
|
|
51
|
-
|
53
|
+
protected
|
52
54
|
|
53
|
-
|
54
|
-
add_option("-#{method.to_s.gsub(/_/,'-')}", *args)
|
55
|
+
def method_missing(method, *args, &block)
|
56
|
+
add_option("-#{method.to_s.gsub(/_/, '-')}", *args)
|
55
57
|
end
|
56
58
|
|
57
59
|
private
|
58
60
|
|
59
|
-
def add_option
|
60
|
-
|
61
|
-
|
61
|
+
def add_option(option_name, *args)
|
62
|
+
@command_options << {
|
63
|
+
name: option_name,
|
64
|
+
args: args.collect { |a| Shellwords.escape(a.to_s) }.join(' ')
|
65
|
+
}
|
66
|
+
self
|
62
67
|
end
|
63
68
|
|
64
|
-
def run
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
def run(command, opts = {})
|
70
|
+
opts = { timeout: 60 }.merge(opts)
|
71
|
+
command = "gm #{command}"
|
72
|
+
cmd = Subexec.run(command, opts)
|
68
73
|
|
69
74
|
if cmd.exitstatus != 0
|
70
|
-
|
75
|
+
raise UnknownOptionError, "#{command} failed: #{cmd.output}"
|
71
76
|
end
|
72
77
|
ensure
|
73
|
-
|
74
|
-
|
78
|
+
@command_options = []
|
79
|
+
@utility = nil
|
75
80
|
end
|
76
81
|
|
77
|
-
def parse_input(input, output_as_file=true)
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
82
|
+
def parse_input(input, output_as_file = true)
|
83
|
+
if input.is_a?(String)
|
84
|
+
output_as_file ? File.new(input) : input
|
85
|
+
elsif input.is_a?(File) || input.is_a?(Tempfile)
|
86
|
+
output_as_file ? input : input.path
|
87
|
+
else
|
88
|
+
raise TypeError,
|
89
|
+
'You must specify a file as a String, File, or Tempfile object'
|
90
|
+
end
|
85
91
|
end
|
86
|
-
|
87
|
-
|
88
|
-
end
|
92
|
+
end
|
93
|
+
end
|
metadata
CHANGED
@@ -1,27 +1,27 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphicsmagick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chad McGimpsey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-05-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: subexec
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
description: Light ruby wrapper for the GraphicsMagick CLI.
|
@@ -31,7 +31,7 @@ executables: []
|
|
31
31
|
extensions: []
|
32
32
|
extra_rdoc_files: []
|
33
33
|
files:
|
34
|
-
- .gitignore
|
34
|
+
- ".gitignore"
|
35
35
|
- CHANGELOG.md
|
36
36
|
- Gemfile
|
37
37
|
- LICENSE.txt
|
@@ -39,7 +39,6 @@ files:
|
|
39
39
|
- Rakefile
|
40
40
|
- graphicsmagick.gemspec
|
41
41
|
- lib/graphicsmagick.rb
|
42
|
-
- lib/graphicsmagick/.DS_Store
|
43
42
|
- lib/graphicsmagick/image.rb
|
44
43
|
- lib/graphicsmagick/utilities.rb
|
45
44
|
- lib/graphicsmagick/utilities/composite.rb
|
@@ -57,17 +56,17 @@ require_paths:
|
|
57
56
|
- lib
|
58
57
|
required_ruby_version: !ruby/object:Gem::Requirement
|
59
58
|
requirements:
|
60
|
-
- -
|
59
|
+
- - ">="
|
61
60
|
- !ruby/object:Gem::Version
|
62
61
|
version: '0'
|
63
62
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
64
63
|
requirements:
|
65
|
-
- -
|
64
|
+
- - ">="
|
66
65
|
- !ruby/object:Gem::Version
|
67
66
|
version: '0'
|
68
67
|
requirements: []
|
69
68
|
rubyforge_project:
|
70
|
-
rubygems_version: 2.
|
69
|
+
rubygems_version: 2.7.6
|
71
70
|
signing_key:
|
72
71
|
specification_version: 4
|
73
72
|
summary: Light ruby wrapper for the GraphicsMagick CLI.
|
Binary file
|