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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcd48806957dff068d1cbedba35df187f70c8bf8
4
- data.tar.gz: c9546290b760ded7c64c3a1a8d9a2e520b579e6a
3
+ metadata.gz: 0be27d55e45279438bebd74f439291396788032b
4
+ data.tar.gz: 709c806844f962459fb604b2db183a20ed486098
5
5
  SHA512:
6
- metadata.gz: 1613b8f6810c5f13405f107177d290a01508f6beea9895a476dc3dcfdffee3249e1656a55cb15266452c0ce6edd1b7182c3b79ac04cd78f20e45021764a81c4c
7
- data.tar.gz: c764056fddfb227dcd6f4cd9d30d408eae87a99a124753bd3e85fcb540ae1ef1f3b108a95200cd387ab2b83a3ff660f05ae07b5ee5431f270edea2d5d2e13b60
6
+ metadata.gz: d681f992c9f1d9d55b2b8c5430cdcb078324d0b3d536d6f0eaa3e59efc3aa2c0878f23127e106987afa36fa27322d688ae64dd3a9d11c0dd156b90ac54f93537
7
+ data.tar.gz: e1e5f1d25db2160dbe097d5ac4070076685e96d93db73bfac37f8e0a6c984219146cc6e667f27fd0b0bd2c295d9cb804023590e887cce5915024dc79f9c58fef
@@ -1,7 +1,8 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- photo-helper (0.1.5)
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
@@ -6,4 +6,9 @@ class FileHelper
6
6
  def self.ingore_file?(path)
7
7
  IGNORE_FOLDERS.include? directory(path).downcase
8
8
  end
9
+
10
+ def self.is_jpeg?(path)
11
+ extension = File.extname(path)
12
+ [".jpeg", ".jpg"].include? extension.downcase
13
+ end
9
14
  end
@@ -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
@@ -1,3 +1,3 @@
1
1
  module KubeDeploy
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
@@ -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
@@ -29,4 +29,5 @@ Gem::Specification.new do |spec|
29
29
  spec.add_development_dependency "rubocop"
30
30
 
31
31
  spec.add_dependency "thor"
32
+ spec.add_dependency "mini_magick"
32
33
  end
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.5
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 00:00:00.000000000 Z
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