asset-image-opt 0.0.2 → 0.0.3
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.
- data/README.md +19 -9
- data/asset-image-opt.gemspec +1 -1
- data/lib/asset-image-opt.rb +4 -3
- data/lib/asset-image-opt/version.rb +1 -1
- metadata +3 -3
data/README.md
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
# Asset-Image-Opt
|
2
2
|
|
3
|
-
Local assets optimizer for Rails apps
|
3
|
+
Local assets optimizer for Rails apps. It will use lossless compression on every jpeg/jpg and png files in app/assets/images directory and subdirecotires.
|
4
|
+
|
5
|
+
Compression efficiency is 5-15% for free and without quality loss.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
|
-
This gem requires
|
8
|
-
|
9
|
-
|
10
|
-
|
9
|
+
This gem requires image processing utilities
|
10
|
+
|
11
|
+
### Debian/Ubuntu
|
12
|
+
|
13
|
+
sudo apt-get install -y advancecomp gifsicle jpegoptim libjpeg-progs optipng pngcrush
|
14
|
+
|
15
|
+
### OSX
|
11
16
|
|
12
|
-
|
13
|
-
|
17
|
+
brew install advancecomp gifsicle jpegoptim jpeg optipng pngcrush
|
18
|
+
|
19
|
+
### Rails
|
14
20
|
|
15
21
|
Add this line to your application's Gemfile:
|
16
22
|
|
@@ -24,8 +30,12 @@ And then execute:
|
|
24
30
|
Execute:
|
25
31
|
|
26
32
|
bundle exec optimize_images
|
27
|
-
|
28
|
-
It will optimize all images in app/assets/images
|
33
|
+
|
34
|
+
It will optimize all images in app/assets/images and subdirs.
|
35
|
+
|
36
|
+
## TODO
|
37
|
+
* Check if **optipng** and **jpegoptim** is present in the system, show instructions otherwise
|
38
|
+
* Remove test_images from rspec and gem source
|
29
39
|
|
30
40
|
## Contributing
|
31
41
|
|
data/asset-image-opt.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |gem|
|
|
16
16
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
|
-
gem.add_dependency '
|
19
|
+
gem.add_dependency 'image_optim'
|
20
20
|
gem.add_development_dependency 'rspec'
|
21
21
|
end
|
data/lib/asset-image-opt.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "asset-image-opt/version"
|
2
|
-
require '
|
2
|
+
require 'image_optim'
|
3
3
|
require 'thread'
|
4
4
|
|
5
5
|
class AssetImageOpt
|
6
|
-
EXTENSIONS = %w{png jpeg jpg}
|
6
|
+
EXTENSIONS = %w{png jpeg jpg gif}
|
7
7
|
WORKING_DIR = "app/assets/images"
|
8
8
|
|
9
9
|
attr_accessor :files, :initial_size, :optimized_size
|
@@ -11,6 +11,7 @@ class AssetImageOpt
|
|
11
11
|
def initialize
|
12
12
|
@files = AssetImageOpt.get_files
|
13
13
|
@initial_size = get_files_size
|
14
|
+
@optimizer = ImageOptim.new(:pngout => false)
|
14
15
|
end
|
15
16
|
|
16
17
|
def threads_count
|
@@ -71,7 +72,7 @@ class AssetImageOpt
|
|
71
72
|
end
|
72
73
|
|
73
74
|
def optimize_file(file)
|
74
|
-
|
75
|
+
@optimizer.optimize_image!(file)
|
75
76
|
print '.'
|
76
77
|
end
|
77
78
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asset-image-opt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,10 +9,10 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-05-09 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
15
|
+
name: image_optim
|
16
16
|
prerelease: false
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|