photo-helper 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +3 -1
- data/lib/helpers/file_helper.rb +5 -0
- data/lib/photo-helper/compress.rb +52 -0
- data/lib/photo-helper/instagram.rb +0 -2
- data/lib/photo-helper/version.rb +1 -1
- data/lib/photo_helper.rb +2 -0
- data/photo-helper.gemspec +1 -0
- metadata +17 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0be27d55e45279438bebd74f439291396788032b
|
4
|
+
data.tar.gz: 709c806844f962459fb604b2db183a20ed486098
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d681f992c9f1d9d55b2b8c5430cdcb078324d0b3d536d6f0eaa3e59efc3aa2c0878f23127e106987afa36fa27322d688ae64dd3a9d11c0dd156b90ac54f93537
|
7
|
+
data.tar.gz: e1e5f1d25db2160dbe097d5ac4070076685e96d93db73bfac37f8e0a6c984219146cc6e667f27fd0b0bd2c295d9cb804023590e887cce5915024dc79f9c58fef
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
photo-helper (0.1.
|
4
|
+
photo-helper (0.1.6)
|
5
|
+
mini_magick
|
5
6
|
thor
|
6
7
|
|
7
8
|
GEM
|
@@ -13,6 +14,7 @@ GEM
|
|
13
14
|
byebug (9.0.6)
|
14
15
|
coderay (1.1.1)
|
15
16
|
method_source (0.8.2)
|
17
|
+
mini_magick (4.8.0)
|
16
18
|
minitest (5.10.3)
|
17
19
|
minitest-reporters (1.1.14)
|
18
20
|
ansi
|
data/lib/helpers/file_helper.rb
CHANGED
@@ -0,0 +1,52 @@
|
|
1
|
+
require "mini_magick"
|
2
|
+
require "helpers/file_helper"
|
3
|
+
|
4
|
+
module PhotoHelper
|
5
|
+
class Compress < Thor
|
6
|
+
include Thor::Actions
|
7
|
+
|
8
|
+
method_option :recursive, aliases: "-r", type: :boolean, default: false
|
9
|
+
method_option :overwrite, aliases: "-f", type: :boolean, default: false
|
10
|
+
desc "images", "compress images in folder"
|
11
|
+
def images(folder=nil)
|
12
|
+
folder ||= options[:folder]
|
13
|
+
|
14
|
+
search_path = File.expand_path(folder)
|
15
|
+
|
16
|
+
files =
|
17
|
+
if options[:recursive]
|
18
|
+
Dir["#{search_path}/**/*"]
|
19
|
+
else
|
20
|
+
Dir["#{search_path}/*"]
|
21
|
+
end
|
22
|
+
|
23
|
+
files.each do |file|
|
24
|
+
next if File.basename(file, ".*").end_with? (".min")
|
25
|
+
next unless FileHelper.is_jpeg?(file)
|
26
|
+
|
27
|
+
image = MiniMagick::Image.open(file)
|
28
|
+
orig_size = image.size
|
29
|
+
|
30
|
+
image.combine_options do |b|
|
31
|
+
b.sampling_factor "4:2:0"
|
32
|
+
b.strip
|
33
|
+
b.interlace "JPEG"
|
34
|
+
b.colorspace "RGB"
|
35
|
+
b.quality 85
|
36
|
+
end
|
37
|
+
puts "#{file} (#{(orig_size / image.size) * 100}%)"
|
38
|
+
|
39
|
+
output_path =
|
40
|
+
if options[:overwrite]
|
41
|
+
file
|
42
|
+
else
|
43
|
+
File.join( File.dirname(file), File.basename(file, ".*") + ".min" + File.extname(file))
|
44
|
+
end
|
45
|
+
|
46
|
+
image.write output_path
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
default_task :images
|
51
|
+
end
|
52
|
+
end
|
@@ -37,13 +37,11 @@ module PhotoHelper
|
|
37
37
|
|
38
38
|
files.each do |file|
|
39
39
|
folder = FileHelper.directory(file).downcase
|
40
|
-
puts folder
|
41
40
|
next unless PhotoHelper::Instagram.folders.include? (folder)
|
42
41
|
pictures.concat([file])
|
43
42
|
end
|
44
43
|
return unless pictures.any?
|
45
44
|
|
46
|
-
puts pictures
|
47
45
|
PhotoHelper::Instagram.osascript <<-END
|
48
46
|
tell application "Photos"
|
49
47
|
activate
|
data/lib/photo-helper/version.rb
CHANGED
data/lib/photo_helper.rb
CHANGED
@@ -7,6 +7,7 @@ require 'photo-helper/generate'
|
|
7
7
|
require 'photo-helper/delete'
|
8
8
|
require 'photo-helper/move'
|
9
9
|
require 'photo-helper/instagram'
|
10
|
+
require 'photo-helper/compress'
|
10
11
|
|
11
12
|
# todo: move to config file
|
12
13
|
# RAW_EXTENSION = "ORF"
|
@@ -30,5 +31,6 @@ module PhotoHelper
|
|
30
31
|
register PhotoHelper::Delete, :delete, "delete", "Do something else"
|
31
32
|
register PhotoHelper::Instagram, :instagram, "instagram", "Do something else"
|
32
33
|
register PhotoHelper::Move, :move, "move", "Do something else"
|
34
|
+
register PhotoHelper::Compress, :compress, "compress", "Do something else"
|
33
35
|
end
|
34
36
|
end
|
data/photo-helper.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: photo-helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Benjamin Caldwell
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-10-
|
11
|
+
date: 2017-10-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -122,6 +122,20 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: mini_magick
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :runtime
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
125
139
|
description:
|
126
140
|
email:
|
127
141
|
- caldwellbenjamin8@gmail.com
|
@@ -143,6 +157,7 @@ files:
|
|
143
157
|
- lib/helpers/file_helper.rb
|
144
158
|
- lib/helpers/printer.rb
|
145
159
|
- lib/helpers/trash.rb
|
160
|
+
- lib/photo-helper/compress.rb
|
146
161
|
- lib/photo-helper/delete.rb
|
147
162
|
- lib/photo-helper/generate.rb
|
148
163
|
- lib/photo-helper/instagram.rb
|