hcatlin-mini_magick 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +1 -0
- data/VERSION +1 -1
- data/lib/mini_magick.rb +38 -8
- data/test/command_builder_test.rb +1 -1
- data/test/image_test.rb +2 -2
- metadata +10 -4
data/README.rdoc
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.3.
|
1
|
+
1.3.1
|
data/lib/mini_magick.rb
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
require 'tempfile'
|
2
|
-
require 'subexec'
|
3
2
|
|
4
3
|
module MiniMagick
|
5
4
|
class << self
|
6
5
|
attr_accessor :processor
|
6
|
+
attr_accessor :use_subexec
|
7
7
|
attr_accessor :timeout
|
8
8
|
end
|
9
9
|
|
10
|
+
# Subexec only works with 1.9
|
11
|
+
if RUBY_VERSION[0..2].to_f < 1.8
|
12
|
+
self.use_subexec = true
|
13
|
+
require 'subexec'
|
14
|
+
end
|
15
|
+
|
10
16
|
class Error < RuntimeError; end
|
11
17
|
class Invalid < StandardError; end
|
12
18
|
|
@@ -67,7 +73,12 @@ module MiniMagick
|
|
67
73
|
# Get the EXIF original capture as a Time object
|
68
74
|
Time.local(*self["EXIF:DateTimeOriginal"].split(/:|\s+/)) rescue nil
|
69
75
|
when /^EXIF\:/i
|
70
|
-
run_command('identify', '-format', "\"%[#{value}]\"", @path).chop
|
76
|
+
result = run_command('identify', '-format', "\"%[#{value}]\"", @path).chop
|
77
|
+
if result.include?(",")
|
78
|
+
read_character_data(result)
|
79
|
+
else
|
80
|
+
result
|
81
|
+
end
|
71
82
|
else
|
72
83
|
run_command('identify', '-format', "\"#{value}\"", @path).split("\n")[0]
|
73
84
|
end
|
@@ -159,20 +170,28 @@ module MiniMagick
|
|
159
170
|
end
|
160
171
|
|
161
172
|
command = "#{MiniMagick.processor} #{command} #{args.join(' ')}".strip
|
162
|
-
|
173
|
+
|
174
|
+
if ::MiniMagick.use_subexec
|
175
|
+
sub = Subexec.run(command, :timeout => MiniMagick.timeout)
|
176
|
+
exit_status = sub.exitstatus
|
177
|
+
output = sub.output
|
178
|
+
else
|
179
|
+
output = `#{command} 2>&1`
|
180
|
+
exit_status = $?.exitstatus
|
181
|
+
end
|
163
182
|
|
164
|
-
if
|
183
|
+
if exit_status != 0
|
165
184
|
# Clean up after ourselves in case of an error
|
166
185
|
destroy!
|
167
186
|
|
168
187
|
# Raise the appropriate error
|
169
|
-
if
|
170
|
-
raise Invalid,
|
188
|
+
if output =~ /no decode delegate/i || output =~ /did not return an image/i
|
189
|
+
raise Invalid, output
|
171
190
|
else
|
172
|
-
raise Error, "Command (#{command.inspect}) failed: #{{:status_code =>
|
191
|
+
raise Error, "Command (#{command.inspect}) failed: #{{:status_code => exit_status, :output => output}.inspect}"
|
173
192
|
end
|
174
193
|
else
|
175
|
-
|
194
|
+
output
|
176
195
|
end
|
177
196
|
end
|
178
197
|
|
@@ -181,6 +200,17 @@ module MiniMagick
|
|
181
200
|
File.unlink(tempfile.path)
|
182
201
|
@tempfile = nil
|
183
202
|
end
|
203
|
+
|
204
|
+
private
|
205
|
+
# Sometimes we get back a list of character values
|
206
|
+
def read_character_data(list_of_characters)
|
207
|
+
chars = list_of_characters.gsub(" ", "").split(",")
|
208
|
+
result = ""
|
209
|
+
chars.each do |val|
|
210
|
+
result << ("%c" % val.to_i)
|
211
|
+
end
|
212
|
+
result
|
213
|
+
end
|
184
214
|
end
|
185
215
|
|
186
216
|
class CommandBuilder
|
data/test/image_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test/unit'
|
2
|
-
require File.
|
2
|
+
require File.expand_path('../../lib/mini_magick', __FILE__)
|
3
3
|
|
4
|
-
MiniMagick.processor = :gm
|
4
|
+
#MiniMagick.processor = :gm
|
5
5
|
|
6
6
|
class ImageTest < Test::Unit::TestCase
|
7
7
|
include MiniMagick
|
metadata
CHANGED
@@ -1,15 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcatlin-mini_magick
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 25
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 1
|
7
8
|
- 3
|
8
|
-
-
|
9
|
-
version: 1.3.
|
9
|
+
- 1
|
10
|
+
version: 1.3.1
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Corey Johnson
|
14
|
+
- Hampton Catlin
|
13
15
|
- Peter Kieltyka
|
14
16
|
autorequire:
|
15
17
|
bindir: bin
|
@@ -26,6 +28,7 @@ dependencies:
|
|
26
28
|
requirements:
|
27
29
|
- - ~>
|
28
30
|
- !ruby/object:Gem::Version
|
31
|
+
hash: 27
|
29
32
|
segments:
|
30
33
|
- 0
|
31
34
|
- 0
|
@@ -33,9 +36,10 @@ dependencies:
|
|
33
36
|
version: 0.0.2
|
34
37
|
type: :runtime
|
35
38
|
version_requirements: *id001
|
36
|
-
description:
|
39
|
+
description: ""
|
37
40
|
email:
|
38
41
|
- probablycorey@gmail.com
|
42
|
+
- hcatlin@gmail.com
|
39
43
|
- peter@nulayer.com
|
40
44
|
executables: []
|
41
45
|
|
@@ -60,7 +64,7 @@ files:
|
|
60
64
|
- test/simple.gif
|
61
65
|
- test/trogdor.jpg
|
62
66
|
has_rdoc: true
|
63
|
-
homepage: http://github.com/
|
67
|
+
homepage: http://github.com/hcatlin/mini_magick
|
64
68
|
licenses: []
|
65
69
|
|
66
70
|
post_install_message:
|
@@ -73,6 +77,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
73
77
|
requirements:
|
74
78
|
- - ">="
|
75
79
|
- !ruby/object:Gem::Version
|
80
|
+
hash: 3
|
76
81
|
segments:
|
77
82
|
- 0
|
78
83
|
version: "0"
|
@@ -81,6 +86,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
81
86
|
requirements:
|
82
87
|
- - ">="
|
83
88
|
- !ruby/object:Gem::Version
|
89
|
+
hash: 3
|
84
90
|
segments:
|
85
91
|
- 0
|
86
92
|
version: "0"
|