image_proc 2.0.0 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ === 2.1.0 / 2011-07-19
2
+
3
+ * Check if the convert bin is available and try to intuit it's path
4
+
1
5
  === 2.0.0 / 2009-01-09
2
6
 
3
7
  * Make all methods return the destination path only
@@ -9,7 +9,7 @@ require 'open3'
9
9
  # The whole idea is: a backend does not have to support cropping (we don't do it), it has only to be able to resize,
10
10
  # and a backend should have 2 public methods. That's the game.
11
11
  class ImageProc
12
- VERSION = '2.0.0'
12
+ VERSION = '2.1.0'
13
13
 
14
14
  class Error < RuntimeError; end
15
15
  class MissingInput < Error; end
@@ -42,7 +42,7 @@ class ImageProc
42
42
 
43
43
  # Tries to detect the best engine available
44
44
  def detect_engine
45
- if (`which convert` =~ /^\// )
45
+ if ImageProcConvert.available?
46
46
  ImageProcConvert
47
47
  elsif RUBY_PLATFORM =~ /darwin/i
48
48
  ImageProcSips
@@ -267,13 +267,38 @@ end
267
267
 
268
268
  ImageProc.keep_quiet do
269
269
  class ImageProcConvert < ImageProc
270
+ class << self
271
+ attr_accessor :convert_bin
272
+
273
+ def available?
274
+ paths = %w( /usr/local/bin /opt/local/bin /usr/bin /bin)
275
+ begin
276
+ result_path = `which convert`.strip
277
+ return false unless result_path =~ /^\//
278
+
279
+ self.convert_bin = File.dirname(result_path)
280
+ return true
281
+ rescue Errno::ENOENT # Path might be not munged
282
+ paths.each do | p |
283
+ if File.exist?(File.join(p, 'convert'))
284
+ self.convert_bin = p
285
+ return true
286
+ end
287
+ end
288
+ end
289
+
290
+ return false #nope, not avaliable?
291
+ end
292
+
293
+ end
294
+
270
295
  HARMLESS = [/unknown field with tag/]
271
296
  def process_exact
272
- wrap_stderr("convert -filter Gaussian -resize #{@target_w}x#{@target_h}! #{@source} #{@dest}")
297
+ wrap_stderr("#{self.class.convert_bin}/convert -filter Gaussian -resize #{@target_w}x#{@target_h}! #{@source} #{@dest}")
273
298
  end
274
299
 
275
300
  def get_bounds(of)
276
- wrap_stderr("identify #{of}").scan(/(\d+)x(\d+)/)[0].map{|e| e.to_i }
301
+ wrap_stderr("#{self.class.convert_bin}/identify #{of}").scan(/(\d+)x(\d+)/)[0].map{|e| e.to_i }
277
302
  end
278
303
  end
279
304
  end
@@ -100,10 +100,15 @@ if(`which convert`)
100
100
  class TestImageProcConvert < Test::Unit::TestCase
101
101
  def setup
102
102
  super
103
+ ImageProcConvert.available?
103
104
  @processor = ImageProcConvert.new
104
105
  end
105
106
 
106
107
  include ResizeTestHelper
108
+
109
+ def test_avail
110
+ assert ImageProcConvert.available?
111
+ end
107
112
  end
108
113
  end
109
114
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: image_proc
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 2.0.0
5
+ version: 2.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Julik
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-07-04 00:00:00 Z
13
+ date: 2011-07-18 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hoe
@@ -18,9 +18,9 @@ dependencies:
18
18
  requirement: &id001 !ruby/object:Gem::Requirement
19
19
  none: false
20
20
  requirements:
21
- - - ">="
21
+ - - ~>
22
22
  - !ruby/object:Gem::Version
23
- version: 2.9.4
23
+ version: "2.10"
24
24
  type: :development
25
25
  version_requirements: *id001
26
26
  description: A no-frills image resizer, with pluggable backends. No extra software required on OS X