rsips 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +24 -0
- data/Rakefile +2 -0
- data/lib/rsips/image.rb +30 -0
- data/lib/rsips/version.rb +3 -0
- data/lib/rsips.rb +6 -0
- data/rsips.gemspec +20 -0
- metadata +53 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
## Ruby sips
|
2
|
+
`sips` is an extremely fast image processing utility that ships with OS X. It is not nearly as robust as, say, ImageMagick, but therein lies its beauty.
|
3
|
+
|
4
|
+
**rsips** seeks to expand on `sips` (but not too much) and might prove to be helpful in your everyday scripting, Rakefiles, static compilers, etc.
|
5
|
+
|
6
|
+
## Install
|
7
|
+
|
8
|
+
gem install rsips
|
9
|
+
|
10
|
+
## Basic Usage
|
11
|
+
|
12
|
+
require 'rsips'
|
13
|
+
|
14
|
+
image = Rsips::Image.new("photo.jpg")
|
15
|
+
# => @width = "580", @height = "870"
|
16
|
+
|
17
|
+
image.vertical? # => true
|
18
|
+
|
19
|
+
Long edge resizing
|
20
|
+
|
21
|
+
image.resize 300
|
22
|
+
# => @width = "200", @height => "300"
|
23
|
+
|
24
|
+
## More to Come...
|
data/Rakefile
ADDED
data/lib/rsips/image.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
module Rsips
|
2
|
+
class Image
|
3
|
+
|
4
|
+
attr_reader :width, :height
|
5
|
+
|
6
|
+
def initialize img
|
7
|
+
@img = img
|
8
|
+
@width = get_dimension :width
|
9
|
+
@height = get_dimension :height
|
10
|
+
end
|
11
|
+
|
12
|
+
def resize(long_edge)
|
13
|
+
vertical? ? resample(:height, long_edge) : resample(:width, long_edge)
|
14
|
+
end
|
15
|
+
|
16
|
+
def vertical?
|
17
|
+
@height > @width
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def resample(dimension, pixels)
|
23
|
+
system "sips --resample#{dimension.capitalize} #{pixels} #{@img}"
|
24
|
+
end
|
25
|
+
|
26
|
+
def get_dimension(dimension)
|
27
|
+
`sips --getProperty pixel#{dimension.capitalize} #{@img}`.chomp.slice(/\d+$/)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/rsips.rb
ADDED
data/rsips.gemspec
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "rsips/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "rsips"
|
7
|
+
s.version = Rsips::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Jacob Lichner"]
|
10
|
+
s.email = ["jacob.d.lichner@gmail.com"]
|
11
|
+
s.homepage = "http://github.com/jdlich/rsips"
|
12
|
+
s.summary = "Ruby wrapper for OS X's `sips` utility."
|
13
|
+
|
14
|
+
s.rubyforge_project = "rsips"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
end
|
metadata
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rsips
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Jacob Lichner
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-08 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description:
|
15
|
+
email:
|
16
|
+
- jacob.d.lichner@gmail.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- .gitignore
|
22
|
+
- Gemfile
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/rsips.rb
|
26
|
+
- lib/rsips/image.rb
|
27
|
+
- lib/rsips/version.rb
|
28
|
+
- rsips.gemspec
|
29
|
+
homepage: http://github.com/jdlich/rsips
|
30
|
+
licenses: []
|
31
|
+
post_install_message:
|
32
|
+
rdoc_options: []
|
33
|
+
require_paths:
|
34
|
+
- lib
|
35
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
36
|
+
none: false
|
37
|
+
requirements:
|
38
|
+
- - ! '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubyforge_project: rsips
|
49
|
+
rubygems_version: 1.8.7
|
50
|
+
signing_key:
|
51
|
+
specification_version: 3
|
52
|
+
summary: Ruby wrapper for OS X's `sips` utility.
|
53
|
+
test_files: []
|