magick_filter 2.0.2 → 2.0.3

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
  SHA256:
3
- metadata.gz: 5b3a2361a449784dd6949a417b5f22101bd1baf8d0674adb6e2a8b94feb8f36b
4
- data.tar.gz: 87b2d1e05c9e2cc97f10d59a354ca1e9cd4f41c53810ae6fc635b8c8996adc6e
3
+ metadata.gz: 36c322301310dfd866e7bbecf09ae6d062a04c2889f5b4a02957aeefe16ed4cc
4
+ data.tar.gz: 229a25a1f93307f45471a2d58f2bf455dbb88b31d7839968b87a6dc3eab58df8
5
5
  SHA512:
6
- metadata.gz: 9d85ee44518ef7450ef9c802749b59d1ac169b972b6c60865f9d0a748124f4b11abf990bb1eeccb1a79adcae95508945c52ec0955ff404731213375303c595fd
7
- data.tar.gz: 5723f31c9c3ffb090cda30e13d4cdce470d11db12197bd6531ebed5083e3ef9df222d83dc46fc832be72ef80c2c69c0712e059c8c970ae1743eab3259db5b223
6
+ metadata.gz: e43fe24963e37da68e5a50353b5b39f0812b466234e9b70f59026c09be778487a0413d95b617ee8b30bf4ffc564f4adedb165f8a886c16c2a433f212485d3677
7
+ data.tar.gz: 650d3e679ae154013b82bc4e0667119a36aa05c24d6d5e8f4c25d3e11d9559411915b40ebbe5019f2c0e4afaa622c2b57b1b87246249fa9629b1b7712adc09b2
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  # MagickFilter
4
4
 
5
- A powerful yet very simple to use gem to apply all sorts of cool instagram types of filters to your images or photos in your Ruby on Rails application. With this gem you can use all sorts of filters like Poster, Sepia, Navy, Sketch etc. You can apply frames of different colours to your images or photos as well.
5
+ A powerful yet very simple to use gem to apply all sorts of cool instagram types of filters to your images or photos in your Ruby on Rails application. With this gem you can use all sorts of filters like Poster, Sepia, Navy, Sketch etc. You can apply frames of different types of frames with different colours to your images or photos as well.
6
6
 
7
7
  This Gem is an attempt to build Ruby Gem and release it to [rubygems.org](https://rubygems.org). Latest version of this gem allows you to add frame to existing photo. This Gem is in early stage. I'll keep on adding some more filters and features with time.
8
8
 
@@ -26,20 +26,40 @@ Or install it yourself as:
26
26
  $ gem install magick_filter
27
27
 
28
28
  ## Usage
29
- 1. Latest version of this Gem supports adding frame to photo with different colors. You can choose any desired color for frame from [ImageMagick color list](https://www.imagemagick.org/script/color.php)
29
+ 1. Latest version of this Gem supports adding frames to photo with different colors. You can choose any desired color for frame from [ImageMagick color list](https://www.imagemagick.org/script/color.php)
30
+ ```ruby
31
+ MagickFilter::Tool.apply_frame(image_path, frame_color, frame_type)
32
+ ```
33
+
34
+ ```ruby
35
+ a) Option 1st => Basic Frame
36
+ MagickFilter::Tool.apply_frame(image_path, "snow", "basic")
37
+ b) Option 2nd => Sunken Frame
38
+ MagickFilter::Tool.apply_frame(image_path, "snow", "sunken")
39
+ ```
30
40
  ```ruby
31
- a) MagickFilter::Tool.apply_frame(image_path, "snow")
32
- b) MagickFilter::Tool.apply_frame(image_path, "LightPink")
33
- c) MagickFilter::Tool.apply_frame(image_path, "SlateBlue1")
34
- d) MagickFilter::Tool.apply_frame(image_path, "SpringGreen4")
41
+ Different color options example -
42
+ a) MagickFilter::Tool.apply_frame(image_path, "snow", "basic")
43
+ b) MagickFilter::Tool.apply_frame(image_path, "LightPink", "BASIC")
44
+ c) MagickFilter::Tool.apply_frame(image_path, "SlateBlue1", :basic)
35
45
  ```
46
+
47
+ ### Default frame type is "basic", frame_type is case insensitive. You can add "basic", "BASIC" or :basic
48
+
36
49
  2. In present there are 12 filters available in this Gem. Use the given below commands ( from Filter Examples section ) on console to convert photos.
50
+ ```ruby
51
+ MagickFilter::Tool.process(image_path, filter_type)
52
+ ```
53
+
37
54
  ```ruby
38
55
  a) MagickFilter::Tool.process(image_path, "sketch")
39
- b) MagickFilter::Tool.process(image_path, "bright")
40
- c) MagickFilter::Tool.process(image_path, "sepia")
56
+ b) MagickFilter::Tool.process(image_path, "BRIGHT")
57
+ c) MagickFilter::Tool.process(image_path, :sepia)
41
58
  d) MagickFilter::Tool.process(image_path, "rough")
42
59
  ```
60
+
61
+ ### Filter type is case insensitive, you can add "sketch", "SKETCH" or :sketch
62
+
43
63
  ## Frame Examples
44
64
 
45
65
  ### Original Image
@@ -47,33 +67,33 @@ Or install it yourself as:
47
67
  <img src="/test_image/test.jpg" alt="Original" width=450 height=298 />
48
68
 
49
69
 
50
- ### Snow Color Frame
70
+ ### Snow Color Frame with basic frame
51
71
 
52
- **`MagickFilter::Tool.apply_frame(image_path, "snow")`**
72
+ **`MagickFilter::Tool.apply_frame(image_path, "snow", "basic")`**
53
73
 
54
74
 
55
75
  <img src="/test_image/snow.jpg" alt="snow" width=450 height=298 />
56
76
 
57
77
 
58
- ### LightPink Color Frame
78
+ ### LightPink Color Frame with sunken frame
59
79
 
60
- **`MagickFilter::Tool.apply_frame(image_path, "LightPink")`**
80
+ **`MagickFilter::Tool.apply_frame(image_path, "LightPink", "sunken")`**
61
81
 
62
82
 
63
83
  <img src="/test_image/lightpink.jpg" alt="LightPink" width=450 height=298 />
64
84
 
65
85
 
66
- ### Orchid1 Color Frame
86
+ ### Orchid1 Color Frame with basic frame
67
87
 
68
- **`MagickFilter::Tool.apply_frame(image_path, "orchid1")`**
88
+ **`MagickFilter::Tool.apply_frame(image_path, "orchid1", "basic")`**
69
89
 
70
90
 
71
91
  <img src="/test_image/orchid1.jpg" alt="orchid1" width=450 height=298 />
72
92
 
73
93
 
74
- ### SlateBlue1 Color Frame
94
+ ### SlateBlue1 Color Frame with sunken frame
75
95
 
76
- **`MagickFilter::Tool.apply_frame(image_path, "SlateBlue1")`**
96
+ **`MagickFilter::Tool.apply_frame(image_path, "SlateBlue1", "sunken")`**
77
97
 
78
98
 
79
99
  <img src="/test_image/slateblue1.jpg" alt="SlateBlue1" width=450 height=298 />
@@ -12,9 +12,10 @@ module Filter
12
12
  rough: "-dither FloydSteinberg -colors 8",
13
13
  sepia: "-sepia-tone 80%"}
14
14
 
15
- FRAME_TYPE = "-mattecolor Tomato -frame 20x20+10+10"
15
+ FRAME_TYPE = {basic: "-mattecolor Tomato -frame 20x20+10+10", sunken: "-mattecolor Tomato -frame 20x20+0+20" }
16
+
17
+ WRITE_PATH = "/tmp"
16
18
 
17
- WRITE_PATH = "/tmp"
18
19
  end
19
20
 
20
21
 
@@ -1,91 +1,95 @@
1
1
  require "magick_filter/version"
2
2
  require "filter"
3
-
3
+
4
4
  module MagickFilter
5
5
  class Tool
6
- def self.process(path='', effect='')
7
- parameter_missing?(path, effect)
8
- parse_if_image(path)
9
- out_file = build_out_file_name(path)
10
- out_file = cmd_convert(path, out_file, effect)
11
- end
6
+ def self.process(path='', effect='')
7
+ parameter_missing?(path, effect, "effect")
8
+ parse_if_image(path)
9
+ out_file = build_out_file_name(path)
10
+ out_file = cmd_convert(path, out_file, effect)
11
+ end
12
+
13
+ def self.apply_frame(path='', color_type='', frame_style=nil)
14
+ parameter_missing?(path, color_type, "frame")
15
+ parse_if_image(path)
16
+ out_file = build_out_file_name(path)
17
+ out_file = cmd_convert_frame(path, out_file, color_type, frame_style)
18
+ end
19
+
20
+ def self.root
21
+ File.expand_path('../..',__FILE__)
22
+ end
12
23
 
13
- def self.apply_frame(path='', color_type='')
14
- parameter_missing?(path, color_type)
15
- parse_if_image(path)
16
- out_file = build_out_file_name(path)
17
- out_file = cmd_convert_frame(path, out_file, color_type)
18
- end
24
+ private
19
25
 
20
- def self.root
21
- File.expand_path('../..',__FILE__)
22
- end
23
-
24
- private
26
+ def self.parse_if_image(path)
27
+ file_ext = IO.popen(["file", "--brief", "--mime-type", path], &:read).chomp.split("/").last
28
+ if ["jpeg", "png", "jpg", "JPG", "PNG"].include?(file_ext)
29
+ return true
30
+ else
31
+ raise "**********Provided file isn't a valid Image**********"
32
+ end
33
+ end
25
34
 
26
- def self.parse_if_image(path)
27
- file_ext = IO.popen(["file", "--brief", "--mime-type", path], &:read).chomp.split("/").last
28
- if ["jpeg", "png", "jpg", "JPG", "PNG"].include?(file_ext)
29
- return true
30
- else
31
- raise "**********Provided file isn't a valid Image**********"
32
- end
33
- end
35
+ def self.parameter_missing?(path, effect, called_for)
36
+ err = ''
37
+ if path.blank? && effect.blank?
38
+ err = "***************Image Path and Effect or Frame Color Parameter Missing***********"
39
+ elsif path.blank?
40
+ err = "***************Image Path Missing***********"
41
+ elsif effect.blank?
42
+ err = "***************Effect or Frame Color Parameter Missing***********"
43
+ end
44
+ if err.blank?
45
+ return false
46
+ else
47
+ raise "#{err}"
48
+ end
49
+ end
34
50
 
35
- def self.parameter_missing?(path, effect)
36
- if path.blank? && effect.blank?
37
- err = "***************Image Path and Effect Parameter Missing***********"
38
- elsif path.blank?
39
- err = "***************Image Path Missing***********"
40
- elsif effect.blank?
41
- err = "***************Effect Parameter Missing***********"
42
- end
43
- return false
44
- raise err
45
- end
51
+ def self.cmd(bin, opts)
52
+ #puts "executing: #{c}"
53
+ #system("sudo " << c)
54
+ "#{bin} #{opts}".tap do |c|
55
+ system(c)
56
+ end
57
+ end
46
58
 
47
- def self.cmd(bin, opts)
48
- "#{bin} #{opts}".tap do |c|
49
- #puts "executing: #{c}"
50
- #system("sudo " << c)
51
- system(c)
52
- end
53
- end
59
+ def self.cmd_convert(in_file=nil, out_file=nil, opts)
60
+ #in_file ||= current_source_file
61
+ #out_file ||= current_target_file
62
+ cmd(:convert, "#{in_file} #{get_effect_options(opts)} #{out_file}")
63
+ print "***Your Image is available here to copy at desired location*** - #{out_file}"
64
+ return out_file
65
+ end
54
66
 
55
- def self.cmd_convert(in_file=nil, out_file=nil, opts)
56
- #in_file ||= current_source_file
57
- #out_file ||= current_target_file
58
- cmd(:convert, "#{in_file} #{get_effect_options(opts)} #{out_file}")
59
- print "***Your file is available here to copy in desired location*** - #{out_file}"
60
- return out_file
61
- end
67
+ def self.cmd_convert_frame(in_file=nil, out_file=nil, opt1, opt2)
68
+ cmd(:convert, "#{in_file} #{get_frame_type(opt1, opt2)} #{out_file}")
69
+ print "***Your Image is available here to copy at desired location*** - #{out_file}"
70
+ return out_file
71
+ end
62
72
 
63
- def self.cmd_convert_frame(in_file=nil, out_file=nil, opts)
64
- #in_file ||= current_source_file
65
- #out_file ||= current_target_file
66
- cmd(:convert, "#{in_file} #{get_frame_type(opts)} #{out_file}")
67
- print "***Your file is available here to copy in desired location*** - #{out_file}"
68
- return out_file
69
- end
73
+ def self.build_out_file_name(path)
74
+ return "#{Filter::WRITE_PATH}/#{next_uuid}_output.#{get_file_extension(path)}"
75
+ end
70
76
 
71
- def self.build_out_file_name(path)
72
- return "#{Filter::WRITE_PATH}/#{next_uuid}_output.#{get_file_extension(path)}"
73
- end
77
+ def self.get_file_extension(path)
78
+ File.extname(path).strip.downcase[1..-1]
79
+ end
74
80
 
75
- def self.get_file_extension(path)
76
- File.extname(path).strip.downcase[1..-1]
77
- end
81
+ def self.next_uuid
82
+ rand(36**16).to_s(36)
83
+ end
78
84
 
79
- def self.next_uuid
80
- rand(36**16).to_s(36)
81
- end
82
-
83
- def self.get_effect_options(effect)
84
- Filter::EFFECT_MAP[effect.downcase.to_sym]
85
- end
85
+ def self.get_effect_options(effect)
86
+ Filter::EFFECT_MAP[effect.downcase.to_sym]
87
+ end
86
88
 
87
- def self.get_frame_type(color_type)
88
- Filter::FRAME_TYPE.gsub("Tomato", color_type)
89
- end
89
+ def self.get_frame_type(color_type, frame_style)
90
+ frame_style ||= "basic"
91
+ frame_type = Filter::FRAME_TYPE[frame_style.downcase.to_sym]
92
+ frame_type = frame_type.gsub("Tomato", color_type)
93
+ end
90
94
  end
91
95
  end
@@ -1,4 +1,4 @@
1
1
  module MagickFilter
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
4
4
 
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.email = ["er.arvind02@gmail.com"]
11
11
 
12
12
  spec.summary = %q{Apply Filters or Frames on Photo or Image}
13
- spec.description = %q{A powerful yet very simple to use gem to apply all sorts of cool instagram types of filters to your images or photos in your Ruby on Rails application. With this gem you can use all sorts of filters like Poster, Sepia, Navy, Sketch etc. You can apply frames of different colours to your images or photos. Pick any colour for frames from https://www.imagemagick.org/script/color.php }
13
+ spec.description = %q{A powerful yet very simple to use gem to apply all sorts of cool instagram types of filters to your images or photos in your Ruby on Rails application. With this gem you can use all sorts of filters like Poster, Sepia, Navy, Sketch etc. You can apply frames ( In present tow types of frames ) of different colours to your images or photos. Pick any colour for frames from https://www.imagemagick.org/script/color.php }
14
14
  spec.homepage = "https://github.com/arvind02/magick_filter"
15
15
  spec.license = "MIT"
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
Binary file
Binary file
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magick_filter
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - arvind02
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-06-12 00:00:00.000000000 Z
11
+ date: 2018-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -55,8 +55,8 @@ dependencies:
55
55
  description: 'A powerful yet very simple to use gem to apply all sorts of cool instagram
56
56
  types of filters to your images or photos in your Ruby on Rails application. With
57
57
  this gem you can use all sorts of filters like Poster, Sepia, Navy, Sketch etc.
58
- You can apply frames of different colours to your images or photos. Pick any colour
59
- for frames from https://www.imagemagick.org/script/color.php '
58
+ You can apply frames ( In present tow types of frames ) of different colours to
59
+ your images or photos. Pick any colour for frames from https://www.imagemagick.org/script/color.php '
60
60
  email:
61
61
  - er.arvind02@gmail.com
62
62
  executables: []