mitty 0.1.0.pre → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -1
- data/lib/mitty/cli.rb +12 -8
- data/lib/mitty/configuration.rb +7 -5
- data/lib/mitty/darkroom.rb +12 -2
- data/lib/mitty/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b68cca53eda9839548e57696706351288254e0f6
|
4
|
+
data.tar.gz: 39677bcd9b472021d3e7c3cdb0bbdad37c39d080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8acdba697064b6bc79fc936a793d27dd9150a1d748bce66f6924521f1b924d21e224f3b7ada260e850c91c3741a61fbc85d6dcf1db19ef529e56ffe079a58631
|
7
|
+
data.tar.gz: 622858b4a24344652dc10bcf1ff547c92548a84dcdfd40492b20f4bff2199c125650d047adb9b27f657921ac3fd6553eb81e4f15fd92e569e4c21ee402d4919a
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ And then execute:
|
|
27
27
|
|
28
28
|
Or install it yourself as:
|
29
29
|
|
30
|
-
$ gem install mitty
|
30
|
+
$ gem install mitty
|
31
31
|
|
32
32
|
## Configuration
|
33
33
|
The `mitty` gem can currently be configured with a `.mitty` file in your home directory, or a `.mitty` file in the directory in which you are executing the gem. A configuration file can also be passed in to the CLI commands directly by providing the `-c` argument.
|
@@ -71,13 +71,22 @@ small_image_size: 250
|
|
71
71
|
medium_image_size: 500
|
72
72
|
large_image_size: 1000
|
73
73
|
|
74
|
+
# This value sets the quality level for normal resized versions of images
|
75
|
+
normal_quality_value: 95
|
76
|
+
|
74
77
|
# This value sets the quality level for low quality versions of images
|
75
78
|
low_quality_value: 25
|
76
79
|
|
77
80
|
## Miscellaneous Config
|
78
81
|
|
79
82
|
# Controls whether or not low quality duplicates of images will be generated
|
83
|
+
# Useful for loading lower quality images first and replacing with their higher
|
84
|
+
# quality counterparts after the page has loaded
|
80
85
|
generate_low_quality: true
|
86
|
+
|
87
|
+
# Controls whether or not image color profiles and comments should be removed
|
88
|
+
# Stripping out this metadata will result in lower filesizes
|
89
|
+
strip_color_profiles: true
|
81
90
|
```
|
82
91
|
|
83
92
|
## Usage
|
data/lib/mitty/cli.rb
CHANGED
@@ -7,7 +7,7 @@ module Mitty
|
|
7
7
|
class_option :verbose, type: :boolean, aliases: '-v'
|
8
8
|
|
9
9
|
desc 'mitty resize PATH', 'Resizes a directory of images to a given size'
|
10
|
-
option :output,
|
10
|
+
option :output, desc: 'Path of the output directory', aliases: '-o'
|
11
11
|
option :config, desc: 'Path to an optional config file', aliases: '-c'
|
12
12
|
option :size, default: 'all',
|
13
13
|
enum: ['all', 'thumbs'].concat(Darkroom::IMAGE_SIZES),
|
@@ -16,7 +16,7 @@ module Mitty
|
|
16
16
|
def resize(path = '.')
|
17
17
|
apply_custom_config
|
18
18
|
|
19
|
-
darkroom = Darkroom.new(path,
|
19
|
+
darkroom = Darkroom.new(path, output_path(path))
|
20
20
|
|
21
21
|
verbose_log("Resizing jpg images in #{path} to the following size: #{options[:size]}")
|
22
22
|
case options[:size]
|
@@ -58,7 +58,7 @@ module Mitty
|
|
58
58
|
end
|
59
59
|
|
60
60
|
desc 'mitty manage PATH', 'Creates a variety of sizes, copies originals, and uploads to an AWS S3 Bucket'
|
61
|
-
option :output,
|
61
|
+
option :output, desc: 'Path of the output directory', aliases: '-o'
|
62
62
|
option :access_key_id, desc: 'AWS access key ID', aliases: '-a'
|
63
63
|
option :secret_access_key, desc: 'AWS secret access key', aliases: '-s'
|
64
64
|
option :aws_bucket, desc: 'AWS bucket identifier', aliases: '-b'
|
@@ -68,7 +68,7 @@ module Mitty
|
|
68
68
|
apply_aws_credential_overrides
|
69
69
|
|
70
70
|
verbose_log("Processing jpg images in #{path}")
|
71
|
-
darkroom = Darkroom.new(path,
|
71
|
+
darkroom = Darkroom.new(path, output_path(path))
|
72
72
|
darkroom.create_thumbnails
|
73
73
|
resized_images_output_path = darkroom.create_all_sizes
|
74
74
|
originals_output_path = darkroom.copy_originals
|
@@ -114,11 +114,15 @@ module Mitty
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def apply_aws_credential_overrides
|
117
|
-
Mitty.configuration.
|
118
|
-
Mitty.configuration.
|
117
|
+
Mitty.configuration.aws_access_key_id = ENV['AWS_ACCESS_KEY_ID'] if ENV['AWS_ACCESS_KEY_ID']
|
118
|
+
Mitty.configuration.aws_secret_access_key = ENV['AWS_SECRET_ACCESS_KEY'] if ENV['AWS_SECRET_ACCESS_KEY']
|
119
119
|
|
120
|
-
Mitty.configuration.
|
121
|
-
Mitty.configuration.
|
120
|
+
Mitty.configuration.aws_access_key_id = options[:access_key_id] if options[:access_key_id]
|
121
|
+
Mitty.configuration.aws_secret_access_key = options[:secret_access_key] if options[:secret_access_key]
|
122
|
+
end
|
123
|
+
|
124
|
+
def output_path(input_path)
|
125
|
+
options[:output].presence || input_path
|
122
126
|
end
|
123
127
|
end
|
124
128
|
|
data/lib/mitty/configuration.rb
CHANGED
@@ -8,10 +8,8 @@ module Mitty
|
|
8
8
|
|
9
9
|
# Image Config
|
10
10
|
attr_accessor :thumbnail_image_size, :small_image_size, :medium_image_size,
|
11
|
-
:large_image_size, :low_quality_value
|
12
|
-
|
13
|
-
# Miscellaneous Config
|
14
|
-
attr_accessor :generate_low_quality
|
11
|
+
:large_image_size, :normal_quality_value, :low_quality_value,
|
12
|
+
:generate_low_quality, :strip_color_profiles
|
15
13
|
|
16
14
|
def initialize
|
17
15
|
@aws_access_key_id = config_from_file['aws_access_key_id'] || ''
|
@@ -25,12 +23,16 @@ module Mitty
|
|
25
23
|
@small_image_size = config_from_file['small_image_size'] || 250
|
26
24
|
@medium_image_size = config_from_file['medium_image_size'] || 500
|
27
25
|
@large_image_size = config_from_file['large_image_size'] || 1000
|
26
|
+
@normal_quality_value = config_from_file['normal_quality_value'] || 95
|
28
27
|
@low_quality_value = config_from_file['low_quality_value'] || 50
|
29
28
|
|
30
29
|
@generate_low_quality = config_from_file['generate_low_quality'] || false
|
30
|
+
@strip_color_profiles = config_from_file['strip_color_profiles'] || false
|
31
31
|
end
|
32
32
|
|
33
|
-
|
33
|
+
private
|
34
|
+
|
35
|
+
# Internal: Reads config from the default configuration file locations.
|
34
36
|
# First checks for a .mitty file in the current directory, then looks for one in
|
35
37
|
# the user's home directory. Defaults to {} if no configuration file available.
|
36
38
|
#
|
data/lib/mitty/darkroom.rb
CHANGED
@@ -30,7 +30,15 @@ module Mitty
|
|
30
30
|
|
31
31
|
image = Magick::Image.read(jpg_file).first
|
32
32
|
image.resize_to_fill!(Mitty.configuration.thumbnail_image_size)
|
33
|
-
image.
|
33
|
+
image.strip! if Mitty.configuration.strip_color_profiles
|
34
|
+
|
35
|
+
image.write(image_output_path) { self.quality = Mitty.configuration.normal_quality_value }
|
36
|
+
|
37
|
+
if Mitty.configuration.generate_low_quality
|
38
|
+
lq_image_output_path = image_output_path(jpg_file, thumbnail_output_path, '_thumb_lq')
|
39
|
+
image.write(lq_image_output_path) { self.quality = Mitty.configuration.low_quality_value }
|
40
|
+
end
|
41
|
+
|
34
42
|
image.destroy!
|
35
43
|
end
|
36
44
|
|
@@ -83,7 +91,9 @@ module Mitty
|
|
83
91
|
|
84
92
|
image = Magick::Image.read(jpg_file).first
|
85
93
|
image.resize_to_fit!(Mitty.configuration.send("#{size}_image_size"))
|
86
|
-
image.
|
94
|
+
image.strip! if Mitty.configuration.strip_color_profiles
|
95
|
+
|
96
|
+
image.write(image_output_path) { self.quality = Mitty.configuration.normal_quality_value }
|
87
97
|
|
88
98
|
if Mitty.configuration.generate_low_quality
|
89
99
|
lq_image_output_path = image_output_path(jpg_file, resized_images_output_path, "_#{size}_lq")
|
data/lib/mitty/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mitty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tim Downey
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-08-
|
11
|
+
date: 2015-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -179,12 +179,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
179
179
|
version: '2.1'
|
180
180
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
181
181
|
requirements:
|
182
|
-
- - "
|
182
|
+
- - ">="
|
183
183
|
- !ruby/object:Gem::Version
|
184
|
-
version:
|
184
|
+
version: '0'
|
185
185
|
requirements: []
|
186
186
|
rubyforge_project:
|
187
|
-
rubygems_version: 2.
|
187
|
+
rubygems_version: 2.4.8
|
188
188
|
signing_key:
|
189
189
|
specification_version: 4
|
190
190
|
summary: Mitty is a command line utility that lets you create thumbnails, resize
|