piet 0.1.3 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 16621256456a706ddf5849744e2dda16c4fdf4a4
4
+ data.tar.gz: 505853c685fc0f265e2b56b83c13d4a38566e3b8
5
+ SHA512:
6
+ metadata.gz: de96325761b35d3a471406db191a4031c6bd71e47b5fd863beab5b692529952c363828519a1c7f8a1eb423f089797ecdefeab30bcb6316e6c4b04de68a2b73c0
7
+ data.tar.gz: 9b1f84be78683f9d12c322024de53ecf9163d145ec67c2643a7549a9ec466ba04264361e457735b1105630c89e35bbbf9e570a3dd7955ca4e57d553b26178b30
data/README.md CHANGED
@@ -24,6 +24,29 @@ After installing both utils, simply install the gem:
24
24
 
25
25
  gem install piet
26
26
 
27
+
28
+ Easy installation of binaries
29
+ ------------------------------
30
+
31
+ While install binaries (like optipng, jpegoptim) is not a rocket science, it can be hard (or even impossible) for some people. Thinking on this a gem called [piet-binary](https://github.com/loureirorg/piet-binary) was created with theses binaries packed.
32
+ This is a good approach if you are using Heroku as your host provider, or if you are lazy or impatient ;)
33
+
34
+ After install piet, just install piet-binary and add to your Gemfile (if you are using Rails):
35
+ ```bash
36
+ gem install piet-binary
37
+ ```
38
+
39
+ And in your Gemfile
40
+ ```ruby
41
+ gem 'piet'
42
+ gem 'piet-binary'
43
+ ```
44
+
45
+ *PS 1: it's optional to call piet in your Gemfile, because piet-binary already do this. The same is valid to install the gem via command-line: just install the piet-gem and it will install the piet for you.*
46
+
47
+ *PS 2: don't forget to call 'bundle install' if you are using Rails*
48
+
49
+
27
50
  Usage
28
51
  -----
29
52
 
@@ -43,6 +66,8 @@ The options are:
43
66
 
44
67
  * **verbose**: Whether you want to get the output of the command or not. It is interpreted as a Boolean value. Default: false.
45
68
 
69
+ * **quality**: If you wanna add a compression, adjust the quality parameter. Valid values are any integer between 0 and 100 (100 means no compression and highest quality). Default: 100
70
+
46
71
 
47
72
  CarrierWave integration
48
73
  -----------------------
@@ -161,3 +186,4 @@ Changelog
161
186
  * v.0.1.1 Added support for GIFs. Added an extra option to use pngquant (thanks @rogercampos). Solved problems with Carrierwave >= 0.6 (thanks @mllocs and @huacnlee).
162
187
  * v.0.1.2 Fixed some problems with missing processing, thanks to @lentg.
163
188
  * v.0.1.3 Use png_quantizator gem instead of the own implementation.
189
+ * v.0.2.0 Users of the gem can now use piet-binary gem thanks to @PikachuEXE. Fix bug with filenames containing spaces, parentheses and some other characters. Requiring png_quantizator when it's due, thanks to @jayzes. Finally, specifying the gem version due to @jigfox interest.
data/lib/piet.rb CHANGED
@@ -1,10 +1,11 @@
1
+ require 'png_quantizator'
1
2
  require 'piet/carrierwave_extension'
2
3
 
3
4
  module Piet
4
5
  class << self
5
6
  VALID_EXTS = %w{ png gif jpg jpeg }
6
7
 
7
- def optimize(path, opts= {} )
8
+ def optimize(path, opts={})
8
9
  output = optimize_for(path, opts)
9
10
  puts output if opts[:verbose]
10
11
  true
@@ -29,12 +30,20 @@ module Piet
29
30
 
30
31
  def optimize_png(path, opts)
31
32
  vo = opts[:verbose] ? "-v" : "-quiet"
32
- `optipng -o7 #{vo} #{path}`
33
+ path.gsub!(/([\(\)\[\]\{\}\*\?\\])/, '\\\\\1')
34
+ `#{command_path("optipng")} -o7 #{opts[:command_options]} #{vo} #{path}`
33
35
  end
34
36
 
35
37
  def optimize_jpg(path, opts)
38
+ quality = (0..100).include?(opts[:quality]) ? opts[:quality] : 100
36
39
  vo = opts[:verbose] ? "-v" : "-q"
37
- `jpegoptim -f --strip-all #{vo} #{path}`
40
+ path.gsub!(/([\(\)\[\]\{\}\*\?\\])/, '\\\\\1')
41
+ `#{command_path("jpegoptim")} -f -m#{quality} --strip-all #{opts[:command_options]} #{vo} #{path}`
38
42
  end
43
+
44
+ def command_path(command)
45
+ command
46
+ end
47
+
39
48
  end
40
49
  end
@@ -1,8 +1,8 @@
1
1
  module Piet
2
2
  module CarrierWaveExtension
3
- def optimize
3
+ def optimize(opts={})
4
4
  manipulate! do |img|
5
- Piet.optimize(img.path)
5
+ Piet.optimize(img.path, opts)
6
6
  img
7
7
  end
8
8
  end
data/lib/piet/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Piet
2
- VERSION = "0.1.3"
2
+ VERSION = "0.2.0"
3
3
  end
data/piet.gemspec CHANGED
@@ -11,6 +11,7 @@ Gem::Specification.new do |s|
11
11
  s.homepage = "http://itnig.net"
12
12
  s.summary = %q{An image optimizer}
13
13
  s.description = %q{-}
14
+ s.license = 'MIT'
14
15
 
15
16
  s.rubyforge_project = "piet"
16
17
 
metadata CHANGED
@@ -1,72 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: piet
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
5
- prerelease:
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Albert Bellonch
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-02-04 00:00:00.000000000 Z
11
+ date: 2014-03-16 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: png_quantizator
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: ZenTest
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ">="
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ">="
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
- description: ! '-'
55
+ description: "-"
63
56
  email:
64
57
  - albert@itnig.net
65
58
  executables: []
66
59
  extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
- - .gitignore
62
+ - ".gitignore"
70
63
  - Gemfile
71
64
  - Gemfile.lock
72
65
  - README.md
@@ -78,28 +71,28 @@ files:
78
71
  - spec/integration/piet_spec.rb
79
72
  - spec/spec_helper.rb
80
73
  homepage: http://itnig.net
81
- licenses: []
74
+ licenses:
75
+ - MIT
76
+ metadata: {}
82
77
  post_install_message:
83
78
  rdoc_options: []
84
79
  require_paths:
85
80
  - lib
86
81
  required_ruby_version: !ruby/object:Gem::Requirement
87
- none: false
88
82
  requirements:
89
- - - ! '>='
83
+ - - ">="
90
84
  - !ruby/object:Gem::Version
91
85
  version: '0'
92
86
  required_rubygems_version: !ruby/object:Gem::Requirement
93
- none: false
94
87
  requirements:
95
- - - ! '>='
88
+ - - ">="
96
89
  - !ruby/object:Gem::Version
97
90
  version: '0'
98
91
  requirements: []
99
92
  rubyforge_project: piet
100
- rubygems_version: 1.8.24
93
+ rubygems_version: 2.2.2
101
94
  signing_key:
102
- specification_version: 3
95
+ specification_version: 4
103
96
  summary: An image optimizer
104
97
  test_files:
105
98
  - spec/integration/piet_spec.rb