phototrim 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MWZmMmE2M2ExZTI4YWNhOWM4MGEzN2E3ODNjNmRkNDcyZGRkNTZjOQ==
5
- data.tar.gz: !binary |-
6
- NTRmZDQ0Nzk4NGU2M2UzNTY0MjM5OTlhMmI0NzViOGQxZTA5YjRmZQ==
2
+ SHA1:
3
+ metadata.gz: 31599b3c8b82161ec1ecf2b9064f09f263ec540a
4
+ data.tar.gz: 6ea7dd28f913d18b957d94f0061f65c596504a76
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- OWE0YzMwZGJhYjU3OGZlMzJmNTU1YTA2ZTUxYjk1N2FjMzNkMWRkZGFmMDA0
10
- ZjM1ZDNiOGNiNWVhZTQ1ZGY5NjA1OTAwMWQxNDc3YjFlNzMzYjA4MzdmMTMz
11
- YmQyYzQ5NjE5MzI4Mzk1YjI2MWIwNWY0NTA2Y2IzZTQ0YTJjNjE=
12
- data.tar.gz: !binary |-
13
- YTg3NWVlNWIwOWYxY2ZmNjk0OTA0YWI0ZWJlNWRlNmIzYWJmOGY0ZjhjNjk2
14
- NTIwZThlMDcxN2UyNDhkNmFkZTE4OGVhYjY1ZTFkN2JhZTQ2MTNhOWM5YzY1
15
- ZTBiMDQ4MTJlMDgyNmRlNmU3ZWI4YzlkNzY4NTliMjhhYTdmNDE=
6
+ metadata.gz: 6c959fd67e158db114f9585d2df953034d1241427b40e19fecf4ca8ebdf8237cc3ab502d3ee4d2c6b449d30298c70cda586d332f7c2fb7765a856fe96c585b12
7
+ data.tar.gz: 082b42ecbaa0129061ff129557d61382643d96df6eef0f02fba9c344ceb21d98e63eca38b7589cd271b40c2db2cc1458319ad4caf6d85f7703dd34e5d3327d94
data/README.md CHANGED
@@ -16,6 +16,25 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install phototrim
18
18
 
19
+ ## Usage
20
+
21
+ The `Phototrim` class makes available to you the `trim max_size, root_dir` function, that you can use to *trim* photos within a directory. Simply do a:
22
+
23
+ ```ruby
24
+
25
+ require 'phototrim'
26
+
27
+ Phototrim.trim max_size_in_px, root_dir
28
+ # example:
29
+ # Phototrim.trim 640, "images"
30
+
31
+ ```
32
+
33
+ Phototrim also shows up as a terminal command you can use. Assuming you want to *trim* photos to a width of 50px within `~/memories/goa_photos`, just do this on your terminal:
34
+
35
+ $ phototrim 50, ~/memories/goa_photos
36
+
37
+ Boom! :)
19
38
 
20
39
  ## Contributing
21
40
 
data/lib/phototrim.rb CHANGED
@@ -6,25 +6,27 @@ require 'RMagick'
6
6
  include Magick
7
7
 
8
8
  class Phototrim
9
- def self.trim(max_size, root_path)
10
- Dir.foreach root_path do |path_object|
11
- unless path_object == "." or path_object == ".." or File.extname(path_object) == ".svg"
12
- if File.directory? File.join(root_path, path_object)
13
- puts "Processing images within #{path_object}..."
14
- trim(max_size, File.join(root_path, path_object))
9
+ def self.trim(max_size, src_path, dest_path=nil)
10
+ unless dest_path
11
+ dest_path = src_path
12
+ end
13
+ Dir.foreach src_path do |src_object|
14
+ unless src_object == "." or src_object == ".." or File.extname(src_object) == ".svg"
15
+ if File.directory? File.join(src_path, src_object)
16
+ puts "Processing images within #{src_object}..."
17
+ trim(max_size, File.join(src_path, src_object), File.join(dest_path, src_object))
15
18
  else
16
- puts "Processing file #{path_object}"
17
- victim = ImageList.new(File.join(root_path, path_object))
19
+ puts "Processing file #{src_object}"
20
+ victim = ImageList.new(File.join(src_path, src_object))
18
21
  if victim.columns > max_size
19
- puts "#{path_object} is beyond #{max_size}px wide, scaling down.."
22
+ puts "#{src_object} is beyond #{max_size}px wide, scaling down.."
20
23
  victim = victim.scale(max_size.to_f/victim.columns)
21
- puts "Scaled down #{path_object}"
22
- victim.write(File.join(root_path, path_object))
24
+ puts "Scaled down #{src_object}"
25
+ victim.write(File.join(dest_path, src_object))
23
26
  end
24
27
  end
25
28
  end
26
29
  end
27
- puts "Done!"
28
30
  end
29
31
  end
30
32
 
@@ -1,3 +1,3 @@
1
1
  module PhototrimVersion
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phototrim
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sarup Banskota
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-02 00:00:00.000000000 Z
11
+ date: 2015-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rmagick
@@ -28,28 +28,28 @@ dependencies:
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '1.6'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '1.6'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rake
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  description: Makes simple calls to RMagick methods and scales photos
@@ -60,7 +60,7 @@ executables:
60
60
  extensions: []
61
61
  extra_rdoc_files: []
62
62
  files:
63
- - .gitignore
63
+ - ".gitignore"
64
64
  - Gemfile
65
65
  - LICENSE.txt
66
66
  - README.md
@@ -79,17 +79,17 @@ require_paths:
79
79
  - lib
80
80
  required_ruby_version: !ruby/object:Gem::Requirement
81
81
  requirements:
82
- - - ! '>='
82
+ - - ">="
83
83
  - !ruby/object:Gem::Version
84
84
  version: '0'
85
85
  required_rubygems_version: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ! '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  requirements: []
91
91
  rubyforge_project:
92
- rubygems_version: 2.2.2
92
+ rubygems_version: 2.4.5
93
93
  signing_key:
94
94
  specification_version: 4
95
95
  summary: Simple gem that helps with resizing a bunch of photos