Module: Ceifpar
- Defined in:
- lib/ceifpar.rb,
lib/ceifpar/version.rb
Constant Summary collapse
- VERSION =
"0.1.2"
Class Method Summary collapse
- .is_jpeg?(path) ⇒ Boolean
- .normalize_ratio(str) ⇒ Object
- .remove_exif!(image) ⇒ Object
- .remove_exif_with_path(path) ⇒ Object
- .resize_image(image, ratio) ⇒ Object
- .resize_image_with_path(path, ratio) ⇒ Object
- .write_image(image, dst_path) ⇒ Object
Class Method Details
.is_jpeg?(path) ⇒ Boolean
32 33 34 35 36 37 38 |
# File 'lib/ceifpar.rb', line 32 def is_jpeg?(path) if File.extname(path).downcase =~ /jpe?g/ return true else return false end end |
.normalize_ratio(str) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/ceifpar.rb', line 40 def normalize_ratio(str) #fraction if str.include?("/") then rat = str.partition("/") ratio = Rational(rat[0].to_f , rat[2].to_f).to_f #percent elsif str.include?("%") then ratio = str.to_f / 100 #decimal else ratio = str.to_f end return ratio end |
.remove_exif!(image) ⇒ Object
21 22 23 |
# File 'lib/ceifpar.rb', line 21 def remove_exif!(image) image.strip! end |
.remove_exif_with_path(path) ⇒ Object
25 26 27 28 29 30 |
# File 'lib/ceifpar.rb', line 25 def remove_exif_with_path(path) return false unless self.is_jpeg?(path) image = Magick::ImageList.new(path) image.strip! end |
.resize_image(image, ratio) ⇒ Object
10 11 12 |
# File 'lib/ceifpar.rb', line 10 def resize_image(image, ratio) image.resize(ratio) end |
.resize_image_with_path(path, ratio) ⇒ Object
14 15 16 17 18 19 |
# File 'lib/ceifpar.rb', line 14 def resize_image_with_path(path, ratio) return false unless self.is_jpeg?(path) image = Magick::ImageList.new(path) image.resize(ratio) end |
.write_image(image, dst_path) ⇒ Object
6 7 8 |
# File 'lib/ceifpar.rb', line 6 def write_image(image, dst_path) image.write(dst_path) end |