image_squeeze 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
data/lib/image_squeeze.rb CHANGED
@@ -15,12 +15,13 @@ require 'image_squeeze/processors/jpeg_tran_progressive_processor'
15
15
  require 'image_squeeze/processors/jpeg_tran_non_progressive_processor'
16
16
  require 'image_squeeze/processors/gifsicle_processor'
17
17
  require 'image_squeeze/processors/gif_to_png_processor'
18
+ require 'image_squeeze/processors/optipng_processor'
18
19
 
19
20
  class ImageSqueeze
20
21
  attr_reader :processors
21
22
  attr_reader :tmpdir
22
23
 
23
- VERSION = '0.1.2'
24
+ VERSION = '0.1.3'
24
25
 
25
26
  # Image Types
26
27
  GIF = 'gif'
@@ -108,6 +109,7 @@ class ImageSqueeze
108
109
  processors << PNGCrushProcessor
109
110
  processors << GIFToPNGProcessor if ImageSqueeze::Utils.image_utility_available?('convert', 'gif')
110
111
  end
112
+ processors << OptiPNGProcessor if ImageSqueeze::Utils.image_utility_available?('optipng', 'png')
111
113
  processors << GifsicleProcessor if ImageSqueeze::Utils.image_utility_available?('gifsicle', 'animated gif')
112
114
  if ImageSqueeze::Utils.image_utility_available?('jpegtran', 'jpeg')
113
115
  processors << JPEGTranProgressiveProcessor
@@ -0,0 +1,11 @@
1
+ class ImageSqueeze
2
+ class OptiPNGProcessor < Processor
3
+ def self.input_type
4
+ PNG
5
+ end
6
+
7
+ def self.squeeze(filename, output_filename)
8
+ system("optipng -i1 -o7 #{filename} -out=#{output_filename} > /dev/null")
9
+ end
10
+ end
11
+ end
@@ -8,6 +8,14 @@ class DefaultProcessorsTest < Test::Unit::TestCase
8
8
  def test_png_crush_processor_with_optimized_png
9
9
  assert_processor_doesnt_optimize_file(ImageSqueeze::PNGCrushProcessor, 'already_optimized_png.png')
10
10
  end
11
+
12
+ def test_optipng_processor_with_unoptimize_png
13
+ assert_processor_optimizes_file(ImageSqueeze::OptiPNGProcessor, 'unoptimized_png.png')
14
+ end
15
+
16
+ def test_optipng_processor_with_optimized_png
17
+ assert_processor_doesnt_optimize_file(ImageSqueeze::OptiPNGProcessor, 'already_optimized_png.png')
18
+ end
11
19
 
12
20
  def test_jpegtran_progressive_processor_with_already_optimized
13
21
  assert_processor_doesnt_optimize_file(ImageSqueeze::JPEGTranProgressiveProcessor, 'already_optimized_jpg.jpg')
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: image_squeeze
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
4
+ hash: 29
5
+ prerelease:
5
6
  segments:
6
7
  - 0
7
8
  - 1
8
- - 2
9
- version: 0.1.2
9
+ - 3
10
+ version: 0.1.3
10
11
  platform: ruby
11
12
  authors:
12
13
  - Andrew Grim
@@ -14,7 +15,7 @@ autorequire:
14
15
  bindir: bin
15
16
  cert_chain: []
16
17
 
17
- date: 2010-05-20 00:00:00 -07:00
18
+ date: 2011-03-21 00:00:00 -07:00
18
19
  default_executable:
19
20
  dependencies: []
20
21
 
@@ -33,6 +34,7 @@ files:
33
34
  - lib/image_squeeze/processors/gifsicle_processor.rb
34
35
  - lib/image_squeeze/processors/jpeg_tran_non_progressive_processor.rb
35
36
  - lib/image_squeeze/processors/jpeg_tran_progressive_processor.rb
37
+ - lib/image_squeeze/processors/optipng_processor.rb
36
38
  - lib/image_squeeze/processors/png_crush_processor.rb
37
39
  - lib/image_squeeze/processors/processor.rb
38
40
  - lib/image_squeeze/result.rb
@@ -71,23 +73,27 @@ rdoc_options: []
71
73
  require_paths:
72
74
  - lib
73
75
  required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
74
77
  requirements:
75
78
  - - ">="
76
79
  - !ruby/object:Gem::Version
80
+ hash: 3
77
81
  segments:
78
82
  - 0
79
83
  version: "0"
80
84
  required_rubygems_version: !ruby/object:Gem::Requirement
85
+ none: false
81
86
  requirements:
82
87
  - - ">="
83
88
  - !ruby/object:Gem::Version
89
+ hash: 3
84
90
  segments:
85
91
  - 0
86
92
  version: "0"
87
93
  requirements:
88
94
  - none
89
95
  rubyforge_project:
90
- rubygems_version: 1.3.6
96
+ rubygems_version: 1.6.2
91
97
  signing_key:
92
98
  specification_version: 3
93
99
  summary: a library for automated lossless image optimization