middleman-images 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 964a7c5425a22aaef41c52646d09bb031e96d651635667f9cc559c02138f9311
4
+ data.tar.gz: ec12a1b00e31d5d597dd081f9f7adfe862e034cab41945113ee11cfdf4ec6b97
5
+ SHA512:
6
+ metadata.gz: c082d6cc1dfbe762e4c6e9c908e135a8b03d2e120bad55a73e8e67b52a4ab76e2f8c8ddcaf56f0b8b1e9f632570918f1a5f628b2c0b9842a0b71247d8668d2c5
7
+ data.tar.gz: afc35215b01e2b7543f00c58fd4952b0c71fa3438791e1d8e774ec43468693ee2212daf159fb69ab47e4c184e2ec2c372a37c1643241aa7e52975a43619b4614
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ # Ignore test files
2
+ /tmp
data/.travis.yml ADDED
@@ -0,0 +1,29 @@
1
+ language: ruby
2
+
3
+ cache: bundler
4
+ before_script:
5
+ - gem install bundler:1.17.3
6
+ rvm:
7
+ - 2.7
8
+ - 2.6
9
+ - 2.5
10
+
11
+ gemfile:
12
+ - Gemfile
13
+ - gemfiles/Gemfile.middleman-5.0-rc
14
+ - gemfiles/Gemfile.middleman-4.3
15
+ - gemfiles/Gemfile.middleman-4.2
16
+ - gemfiles/Gemfile.middleman-4.1
17
+
18
+ jobs:
19
+ fast_finish: true
20
+ # We exclude these, since running Bundler 1 with Ruby 2.7 on Travis is not trivial, but Middleman 4.1/4.2 requires Bundler 1.
21
+ exclude:
22
+ - rvm: 2.7
23
+ gemfile: gemfiles/Gemfile.middleman-4.2
24
+ - rvm: 2.7
25
+ gemfile: gemfiles/Gemfile.middleman-4.1
26
+ allow_failures:
27
+ - gemfile: gemfiles/Gemfile.middleman-5.0-rc
28
+
29
+ script: bundle exec rake test
data/CHANGELOG.md ADDED
@@ -0,0 +1,32 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
5
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [Unreleased]
8
+
9
+ ## [0.1.0] - 2020-02-05
10
+ ### Added
11
+ - Do not resize SVG or GIF files.
12
+ - Added this changelog 🎊.
13
+ - Customizable cache directory by [@pantajosef](https://github.com/pantajosef)
14
+ - Preserve jpg quality when resizing.
15
+ - Ignore original image files by [@pmk1c](https://github.com/pmk1c) and [@TimMoser92](https://github.com/TimMoser92).
16
+ - Support for `image_path` helper by [@juls](https://github.com/juls).
17
+ - Added a README.
18
+ - Image optimization by [@pmk1c](https://github.com/pmk1c).
19
+ - Initial image resizing by [@juls](https://github.com/juls).
20
+
21
+ ### Changed
22
+ - `image_optim` removed as a dependency by [@pantajosef](https://github.com/pantajosef).
23
+ Make sure to include `image_optim` in your Gemfile if you need to optimize images.
24
+ - `mini_magick` removed as a dependency.
25
+ Make sure to include `mini_magick` in you Gemfile if you need to resize images.
26
+ - Images are not optimized by default anymore.
27
+
28
+ ### Removed
29
+ - Removed support for Ruby < 2.5
30
+
31
+ [Unreleased]: https://github.com/zweitag/middleman-images/compare/v0.1.0...HEAD
32
+ [0.1.0]: https://github.com/zweitag/middleman-images/releases/tag/v0.1.0
data/Gemfile ADDED
@@ -0,0 +1,26 @@
1
+ # If you do not have OpenSSL installed, update
2
+ # the following line to use "http://" instead
3
+ source 'https://rubygems.org'
4
+
5
+ # Specify your gem's dependencies in middleman-images.gemspec
6
+ gemspec
7
+
8
+ group :development do
9
+ gem 'middleman', '~> 4.3'
10
+ gem 'rake'
11
+ gem 'rdoc'
12
+ gem 'yard'
13
+ end
14
+
15
+ group :test do
16
+ gem 'cucumber'
17
+ gem 'capybara'
18
+ gem 'aruba'
19
+ gem 'rspec'
20
+
21
+ gem 'image_optim'
22
+ gem 'mini_magick'
23
+
24
+ # Version is locked to make sure asset_hash tests are not broken by updated optimizations.
25
+ gem 'image_optim_pack', '=0.6.0'
26
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,194 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ middleman-images (0.1.0)
5
+ middleman-core (>= 4.1.14)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ activesupport (5.0.7.2)
11
+ concurrent-ruby (~> 1.0, >= 1.0.2)
12
+ i18n (>= 0.7, < 2)
13
+ minitest (~> 5.1)
14
+ tzinfo (~> 1.1)
15
+ addressable (2.7.0)
16
+ public_suffix (>= 2.0.2, < 5.0)
17
+ aruba (0.14.14)
18
+ childprocess (>= 0.6.3, < 4.0.0)
19
+ contracts (~> 0.9)
20
+ cucumber (>= 1.3.19)
21
+ ffi (~> 1.9)
22
+ rspec-expectations (>= 2.99)
23
+ thor (>= 0.19, < 2.0)
24
+ backports (3.15.0)
25
+ builder (3.2.4)
26
+ capybara (3.31.0)
27
+ addressable
28
+ mini_mime (>= 0.1.3)
29
+ nokogiri (~> 1.8)
30
+ rack (>= 1.6.0)
31
+ rack-test (>= 0.6.3)
32
+ regexp_parser (~> 1.5)
33
+ xpath (~> 3.2)
34
+ childprocess (3.0.0)
35
+ coffee-script (2.4.1)
36
+ coffee-script-source
37
+ execjs
38
+ coffee-script-source (1.12.2)
39
+ concurrent-ruby (1.1.5)
40
+ contracts (0.13.0)
41
+ cucumber (3.1.2)
42
+ builder (>= 2.1.2)
43
+ cucumber-core (~> 3.2.0)
44
+ cucumber-expressions (~> 6.0.1)
45
+ cucumber-wire (~> 0.0.1)
46
+ diff-lcs (~> 1.3)
47
+ gherkin (~> 5.1.0)
48
+ multi_json (>= 1.7.5, < 2.0)
49
+ multi_test (>= 0.1.2)
50
+ cucumber-core (3.2.1)
51
+ backports (>= 3.8.0)
52
+ cucumber-tag_expressions (~> 1.1.0)
53
+ gherkin (~> 5.0)
54
+ cucumber-expressions (6.0.1)
55
+ cucumber-tag_expressions (1.1.1)
56
+ cucumber-wire (0.0.1)
57
+ diff-lcs (1.3)
58
+ dotenv (2.7.5)
59
+ erubis (2.7.0)
60
+ execjs (2.7.0)
61
+ exifr (1.3.6)
62
+ fast_blank (1.0.0)
63
+ fastimage (2.1.7)
64
+ ffi (1.12.2)
65
+ fspath (3.1.2)
66
+ gherkin (5.1.0)
67
+ haml (5.1.2)
68
+ temple (>= 0.8.0)
69
+ tilt
70
+ hamster (3.0.0)
71
+ concurrent-ruby (~> 1.0)
72
+ hashie (3.6.0)
73
+ i18n (0.9.5)
74
+ concurrent-ruby (~> 1.0)
75
+ image_optim (0.26.5)
76
+ exifr (~> 1.2, >= 1.2.2)
77
+ fspath (~> 3.0)
78
+ image_size (>= 1.5, < 3)
79
+ in_threads (~> 1.3)
80
+ progress (~> 3.0, >= 3.0.1)
81
+ image_optim_pack (0.6.0)
82
+ fspath (>= 2.1, < 4)
83
+ image_optim (~> 0.19)
84
+ image_size (2.0.2)
85
+ in_threads (1.5.4)
86
+ kramdown (1.17.0)
87
+ listen (3.0.8)
88
+ rb-fsevent (~> 0.9, >= 0.9.4)
89
+ rb-inotify (~> 0.9, >= 0.9.7)
90
+ memoist (0.16.2)
91
+ middleman (4.3.5)
92
+ coffee-script (~> 2.2)
93
+ haml (>= 4.0.5)
94
+ kramdown (~> 1.2)
95
+ middleman-cli (= 4.3.5)
96
+ middleman-core (= 4.3.5)
97
+ middleman-cli (4.3.5)
98
+ thor (>= 0.17.0, < 2.0)
99
+ middleman-core (4.3.5)
100
+ activesupport (>= 4.2, < 5.1)
101
+ addressable (~> 2.3)
102
+ backports (~> 3.6)
103
+ bundler
104
+ contracts (~> 0.13.0)
105
+ dotenv
106
+ erubis
107
+ execjs (~> 2.0)
108
+ fast_blank
109
+ fastimage (~> 2.0)
110
+ hamster (~> 3.0)
111
+ hashie (~> 3.4)
112
+ i18n (~> 0.9.0)
113
+ listen (~> 3.0.0)
114
+ memoist (~> 0.14)
115
+ padrino-helpers (~> 0.13.0)
116
+ parallel
117
+ rack (>= 1.4.5, < 3)
118
+ sassc (~> 2.0)
119
+ servolux
120
+ tilt (~> 2.0.9)
121
+ uglifier (~> 3.0)
122
+ mini_magick (4.10.1)
123
+ mini_mime (1.0.2)
124
+ mini_portile2 (2.4.0)
125
+ minitest (5.14.0)
126
+ multi_json (1.14.1)
127
+ multi_test (0.1.2)
128
+ nokogiri (1.10.7)
129
+ mini_portile2 (~> 2.4.0)
130
+ padrino-helpers (0.13.3.4)
131
+ i18n (~> 0.6, >= 0.6.7)
132
+ padrino-support (= 0.13.3.4)
133
+ tilt (>= 1.4.1, < 3)
134
+ padrino-support (0.13.3.4)
135
+ activesupport (>= 3.1)
136
+ parallel (1.19.1)
137
+ progress (3.5.2)
138
+ public_suffix (4.0.3)
139
+ rack (2.1.2)
140
+ rack-test (1.1.0)
141
+ rack (>= 1.0, < 3)
142
+ rake (13.0.1)
143
+ rb-fsevent (0.10.3)
144
+ rb-inotify (0.10.1)
145
+ ffi (~> 1.0)
146
+ rdoc (6.2.1)
147
+ regexp_parser (1.6.0)
148
+ rspec (3.9.0)
149
+ rspec-core (~> 3.9.0)
150
+ rspec-expectations (~> 3.9.0)
151
+ rspec-mocks (~> 3.9.0)
152
+ rspec-core (3.9.1)
153
+ rspec-support (~> 3.9.1)
154
+ rspec-expectations (3.9.0)
155
+ diff-lcs (>= 1.2.0, < 2.0)
156
+ rspec-support (~> 3.9.0)
157
+ rspec-mocks (3.9.1)
158
+ diff-lcs (>= 1.2.0, < 2.0)
159
+ rspec-support (~> 3.9.0)
160
+ rspec-support (3.9.2)
161
+ sassc (2.2.1)
162
+ ffi (~> 1.9)
163
+ servolux (0.13.0)
164
+ temple (0.8.2)
165
+ thor (1.0.1)
166
+ thread_safe (0.3.6)
167
+ tilt (2.0.10)
168
+ tzinfo (1.2.6)
169
+ thread_safe (~> 0.1)
170
+ uglifier (3.2.0)
171
+ execjs (>= 0.3.0, < 3)
172
+ xpath (3.2.0)
173
+ nokogiri (~> 1.8)
174
+ yard (0.9.24)
175
+
176
+ PLATFORMS
177
+ ruby
178
+
179
+ DEPENDENCIES
180
+ aruba
181
+ capybara
182
+ cucumber
183
+ image_optim
184
+ image_optim_pack (= 0.6.0)
185
+ middleman (~> 4.3)
186
+ middleman-images!
187
+ mini_magick
188
+ rake
189
+ rdoc
190
+ rspec
191
+ yard
192
+
193
+ BUNDLED WITH
194
+ 2.1.4
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2020 Zweitag GmbH
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,142 @@
1
+ # Middleman Images Extension
2
+
3
+ Resize and optimize your images on the fly with Middleman. Just run `middleman build`
4
+ and all your images will get the minimizing treatment. *Middleman Images* currently
5
+ depends on [mini_magick](https://github.com/minimagick/minimagick) for resizing and
6
+ [image_optim](https://github.com/toy/image_optim) for optimizing your images.
7
+
8
+ [![Build Status](https://api.travis-ci.org/zweitag/middleman-images.png?branch=master)](https://travis-ci.org/zweitag/middleman-images)
9
+
10
+ * * *
11
+
12
+ ## Installation
13
+
14
+ ```ruby
15
+ gem 'middleman-images'
16
+
17
+ # For resizing images:
18
+ gem 'mini_magick'
19
+
20
+ # For optimizing images:
21
+ gem 'image_optim'
22
+ ```
23
+
24
+ Resizing images requires the gem `mini_magick` and ImageMagick binaries to be
25
+ available. Check [`mini_magick`](https://github.com/minimagick/minimagick) for
26
+ more information.
27
+
28
+ Optimizing images require the gem `image_optim`.
29
+ Check [`image_optim`](https://github.com/toy/image_optim) for more information.
30
+
31
+ ImageOptim uses different tools to optimize image files. The easiest way to
32
+ make sure, most of these tools are available, is by including them via a seperate
33
+ gem:
34
+
35
+ ```ruby
36
+ gem 'image_optim_pack'
37
+ ```
38
+
39
+ For more information check [`image_optim_pack`](https://github.com/toy/image_optim_pack)
40
+
41
+ ## Configuration
42
+
43
+ To activate the extension just put this into your `config.rb`:
44
+
45
+ ```ruby
46
+ configure :build do
47
+ activate :images
48
+ end
49
+ ```
50
+
51
+ Although it is possible to activate the extension in development mode, we do
52
+ not recommend this. Since this will radically drain the performance.
53
+
54
+ Configure the extension by passing a block to `:activate`:
55
+
56
+ ```ruby
57
+ configure :build do
58
+ activate :images do |images|
59
+ # Do not include original images in the build (default: false)
60
+ images.ignore_original = true
61
+
62
+ # Specify another cache directory depending on your root directory (default: 'cache')
63
+ images.cache_dir = 'funky_cache/subdir_of_funky_cache'
64
+
65
+ # Optimize images (default: false)
66
+ images.optimize = true
67
+
68
+ # Provide additional options for image_optim
69
+ # See https://github.com/toy/image_optim for all available options
70
+ images.image_optim = {
71
+ nice: 20,
72
+ optipng: {
73
+ level: 5,
74
+ },
75
+ }
76
+ end
77
+ end
78
+ ```
79
+
80
+ By default *Middleman Images* won't do anything to your images.
81
+
82
+ ## Usage
83
+
84
+ ### Resize
85
+
86
+ To resize your images, set the option `resize` on the middleman helpers `image_tag` or `image_path`.
87
+
88
+ ```erb
89
+ <%= image_tag 'example.jpg', resize: '200x300' %>
90
+ ```
91
+
92
+ becomes:
93
+
94
+ ```html
95
+ <img src="/assets/images/example-200x300-opt.jpg" alt="Example" />
96
+ ```
97
+
98
+ The image `example.jpg` will be resized, optimized and saved to `example-200x300-opt.jpg`.
99
+
100
+ We use ImageMagick for resizing, which respects the aspect ratio of your images when resizing. You can make ImageMagick ignore the aspect ratio by appending `!` to `resize`.
101
+
102
+ ```erb
103
+ <%= image_tag 'example.jpg', resize: '200x300!' %>
104
+ ```
105
+
106
+ Since *Middleman Images* just passes the `resize` string to ImageMagick, you can use all options available. Check the [ImageMagick documentation for resize](https://www.imagemagick.org/Usage/resize/#resize) for all available options.
107
+
108
+ ### Optimize
109
+
110
+ You can enable (or disable) optimization for some images by providing the `optimize`
111
+ option.
112
+
113
+ ```erb
114
+ <%= image_path 'example.jpg', resize: '200x300', optimize: false %>
115
+ ```
116
+
117
+ becomes:
118
+
119
+ ```html
120
+ /assets/images/example-200x300.jpg
121
+ ```
122
+
123
+ ### srcset
124
+
125
+ Using `srcset` with *Middleman Images* is possible via the `image_path` helper. This is how Middleman handles srcsets in conjunction with the
126
+ `:asset_hash` option
127
+ (see [Middleman#File Size Optimization](https://middlemanapp.com/advanced/file-size-optimization)).
128
+
129
+ ```erb
130
+ <img src="<%= image_path 'example.jpg', resize: '200x300' %>"
131
+ srcset="<%= image_path 'example.jpg', resize: '400x600' %> 2x" />
132
+ ```
133
+
134
+ ### Cache
135
+
136
+ *Middleman Images* will create a `cache` Folder in your app directory
137
+ (or the folder name you specified as `cache_dir`). It will
138
+ save the processed images in there. This is necessary to work with other plugins
139
+ like `asset_hash` and to make sure unchanged images are not reprocessed on
140
+ rebuild. Deleting this directory is not critical, but it will force
141
+ *Middleman Images* to rebuild **all** images on the next build, so you should
142
+ do this with care.