image_proc 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gemtest ADDED
File without changes
data/History.txt CHANGED
@@ -1,3 +1,9 @@
1
+ === 1.0.1 / 2009-01-09
2
+
3
+ * Small updates to Hoe and other software rot prevention
4
+
5
+ * Birthday!
6
+
1
7
  === 1.0.0 / 2009-01-09
2
8
 
3
9
  * 1 major enhancement
data/Manifest.txt CHANGED
File without changes
data/README.txt CHANGED
@@ -14,7 +14,7 @@ A no-frills image resizer, with pluggable backends. No extra software required o
14
14
 
15
15
  (The MIT License)
16
16
 
17
- Copyright (c) 2009 Julik Tarkhanov <me@julik.nl>
17
+ Copyright (c) 2009-2011 Julik Tarkhanov <me@julik.nl>
18
18
 
19
19
  Permission is hereby granted, free of charge, to any person obtaining
20
20
  a copy of this software and associated documentation files (the
data/Rakefile CHANGED
@@ -2,9 +2,6 @@ require 'rubygems'
2
2
  require 'hoe'
3
3
  require './lib/image_proc.rb'
4
4
 
5
- Hoe.new('image_proc', ImageProc::VERSION) do |p|
6
- p.description = 'A no-frills image metadata and resizing'
5
+ Hoe.spec('image_proc') do |p|
7
6
  p.developer('Julik', 'me@julik.nl')
8
- p.rubyforge_name = 'wiretap'
9
- p.remote_rdoc_dir = 'image_proc'
10
7
  end
data/init.rb CHANGED
File without changes
data/lib/image_proc.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'open3'
2
+
1
3
  # A simplistic interface to shell-based image processing. Pluggable, compact and WIN32-incompatible by
2
4
  # design. Sort of like the Processors in attachment_fu but less. Less.
3
5
  #
@@ -6,10 +8,8 @@
6
8
  #
7
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,
8
10
  # and a backend should have 2 public methods. That's the game.
9
- require 'open3'
10
-
11
11
  class ImageProc
12
- VERSION = '0.1.0'
12
+ VERSION = '0.1.1'
13
13
 
14
14
  class Error < RuntimeError; end
15
15
  class MissingInput < Error; end
@@ -21,6 +21,18 @@ class ImageProc
21
21
 
22
22
  HARMLESS = []
23
23
  class << self
24
+
25
+ # Run a block without warnings
26
+ def keep_quiet
27
+ o = $VERBOSE
28
+ begin
29
+ $VERBOSE = nil
30
+ yield
31
+ ensure
32
+ $VERBOSE = o
33
+ end
34
+ end
35
+
24
36
  # Assign a specific processor class
25
37
  def engine=(kls); @@engine = kls; end
26
38
 
@@ -220,7 +232,7 @@ class ImageProc
220
232
  error = err.read.to_s.strip
221
233
  result = outp.read.strip
222
234
  unless self.class::HARMLESS.select{|warning| error =~ warning }.any?
223
- raise Error, "Problem with #{@source}: #{error}" unless error.nil? || error.empty?
235
+ raise Error, "Problem: #{error}" unless error.nil? || error.empty?
224
236
  end
225
237
  [inp, outp, err].map{|socket| begin; socket.close; rescue IOError; end }
226
238
  result
@@ -228,66 +240,72 @@ class ImageProc
228
240
 
229
241
  end
230
242
 
231
- class ImageProcConvert < ImageProc
232
- HARMLESS = [/unknown field with tag/]
233
- def process_exact
234
- wrap_stderr("convert -resize #{@target_w}x#{@target_h}! #{@source} #{@dest}")
235
- end
243
+ ImageProc.keep_quiet do
244
+ class ImageProcConvert < ImageProc
245
+ HARMLESS = [/unknown field with tag/]
246
+ def process_exact
247
+ wrap_stderr("convert -resize #{@target_w}x#{@target_h}! #{@source} #{@dest}")
248
+ end
236
249
 
237
- def get_bounds(of)
238
- wrap_stderr("identify #{of}").scan(/(\d+)x(\d+)/)[0].map{|e| e.to_i }
250
+ def get_bounds(of)
251
+ wrap_stderr("identify #{of}").scan(/(\d+)x(\d+)/)[0].map{|e| e.to_i }
252
+ end
239
253
  end
240
254
  end
241
255
 
242
- class ImageProcRmagick < ImageProc
243
- def get_bounds(of)
244
- run_require
245
- comp = wrap_err { Magick::Image.ping(of)[0] }
246
- res = comp.columns, comp.rows
247
- comp = nil; return res
248
- end
256
+ ImageProc.keep_quiet do
257
+ class ImageProcRmagick < ImageProc
258
+ def get_bounds(of)
259
+ run_require
260
+ comp = wrap_err { Magick::Image.ping(of)[0] }
261
+ res = comp.columns, comp.rows
262
+ comp = nil; return res
263
+ end
249
264
 
250
- def process_exact
251
- run_require
252
- img = wrap_err { Magick::Image.read(@source).first }
253
- img.scale(@target_w, @target_h).write(@dest)
254
- img = nil # deallocate the ref
255
- end
256
- private
257
- def run_require
258
- require 'RMagick' unless defined?(Magick)
265
+ def process_exact
266
+ run_require
267
+ img = wrap_err { Magick::Image.read(@source).first }
268
+ img.scale(@target_w, @target_h).write(@dest)
269
+ img = nil # deallocate the ref
259
270
  end
271
+ private
272
+ def run_require
273
+ require 'RMagick' unless defined?(Magick)
274
+ end
260
275
 
261
- def wrap_err
262
- begin
263
- yield
264
- rescue Magick::ImageMagickError => e
265
- raise Error, e.to_s
276
+ def wrap_err
277
+ begin
278
+ yield
279
+ rescue Magick::ImageMagickError => e
280
+ raise Error, e.to_s
281
+ end
266
282
  end
267
- end
283
+ end
268
284
  end
269
285
 
270
- class ImageProcSips < ImageProc
271
- # -Z pixelsWH --resampleHeightWidthMax pixelsWH
272
- FORMAT_MAP = { ".tif" => "tiff", ".png" => "png", ".tif" => "tiff", ".gif" => "gif" }
273
- HARMLESS = [/XRefStm encountered but/, /CGColor/]
274
- def process_exact
275
- fmt = detect_source_format
276
- wrap_stderr("sips -s format #{fmt} --resampleHeightWidth #{@target_h} #{@target_w} #{@source} --out '#{@dest}'")
277
- end
286
+ ImageProc.keep_quiet do
287
+ class ImageProcSips < ImageProc
288
+ # -Z pixelsWH --resampleHeightWidthMax pixelsWH
289
+ FORMAT_MAP = { ".tif" => "tiff", ".png" => "png", ".tif" => "tiff", ".gif" => "gif" }
290
+ HARMLESS = [/XRefStm encountered but/, /CGColor/]
291
+ def process_exact
292
+ fmt = detect_source_format
293
+ wrap_stderr("sips -s format #{fmt} --resampleHeightWidth #{@target_h} #{@target_w} #{@source} --out '#{@dest}'")
294
+ end
278
295
 
279
- def get_bounds(of)
280
- wrap_stderr("sips #{of} -g pixelWidth -g pixelHeight").scan(/(pixelWidth|pixelHeight): (\d+)/).to_a.map{|e| e[1].to_i}
281
- end
296
+ def get_bounds(of)
297
+ wrap_stderr("sips #{of} -g pixelWidth -g pixelHeight").scan(/(pixelWidth|pixelHeight): (\d+)/).to_a.map{|e| e[1].to_i}
298
+ end
282
299
 
283
- private
284
- def detect_source_format
285
- suspected = FORMAT_MAP[File.extname(@source)]
286
- suspected = (suspected.nil? || suspected.empty?) ? 'jpeg' : suspected
287
- case suspected
288
- when "png", "gif"
289
- raise FormatUnsupported, "SIPS cannot resize indexed color GIF or PNG images, call Apple if you want to know why"
300
+ private
301
+ def detect_source_format
302
+ suspected = FORMAT_MAP[File.extname(@source)]
303
+ suspected = (suspected.nil? || suspected.empty?) ? 'jpeg' : suspected
304
+ case suspected
305
+ when "png", "gif"
306
+ raise FormatUnsupported, "SIPS cannot resize indexed color GIF or PNG images, call Apple if you want to know why"
307
+ end
308
+ return suspected
290
309
  end
291
- return suspected
292
- end
310
+ end
293
311
  end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
data/test/test_geom.rb CHANGED
File without changes
File without changes
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_proc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ prerelease:
5
+ version: 0.1.1
5
6
  platform: ruby
6
7
  authors:
7
8
  - Julik
@@ -9,20 +10,20 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-01-09 00:00:00 +01:00
13
- default_executable:
13
+ date: 2011-06-28 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: hoe
17
- type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: 1.8.2
24
- version:
25
- description: A no-frills image metadata and resizing
23
+ version: 2.9.4
24
+ type: :development
25
+ version_requirements: *id001
26
+ description: A no-frills image resizer, with pluggable backends. No extra software required on OS X
26
27
  email:
27
28
  - me@julik.nl
28
29
  executables: []
@@ -49,8 +50,10 @@ files:
49
50
  - test/resize_test_helper.rb
50
51
  - test/test_geom.rb
51
52
  - test/test_image_proc.rb
52
- has_rdoc: true
53
+ - .gemtest
53
54
  homepage: http://wiretap.rubyforge.org/image_proc
55
+ licenses: []
56
+
54
57
  post_install_message:
55
58
  rdoc_options:
56
59
  - --main
@@ -58,23 +61,23 @@ rdoc_options:
58
61
  require_paths:
59
62
  - lib
60
63
  required_ruby_version: !ruby/object:Gem::Requirement
64
+ none: false
61
65
  requirements:
62
66
  - - ">="
63
67
  - !ruby/object:Gem::Version
64
68
  version: "0"
65
- version:
66
69
  required_rubygems_version: !ruby/object:Gem::Requirement
70
+ none: false
67
71
  requirements:
68
72
  - - ">="
69
73
  - !ruby/object:Gem::Version
70
74
  version: "0"
71
- version:
72
75
  requirements: []
73
76
 
74
- rubyforge_project: wiretap
75
- rubygems_version: 1.3.1
77
+ rubyforge_project: image_proc
78
+ rubygems_version: 1.8.5
76
79
  signing_key:
77
- specification_version: 2
80
+ specification_version: 3
78
81
  summary: A no-frills image resizer, with pluggable backends
79
82
  test_files:
80
83
  - test/test_geom.rb