rsips 0.0.2 → 0.1.0

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/README.md CHANGED
@@ -1,7 +1,7 @@
1
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.
2
+ `sips` is an extremely fast image processing utility that ships with OS X. It's not nearly as robust as ImageMagick but therein lies its beauty.
3
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.
4
+ **rsips** seeks to expand on `sips` and make it fun to use in everyday scripting, Rakefiles, static compilers, etc.
5
5
 
6
6
  ## Install
7
7
 
data/lib/rsips.rb CHANGED
@@ -8,7 +8,7 @@ $:.unshift File.expand_path(File.dirname(__FILE__))
8
8
  module Rsips
9
9
 
10
10
  # Current version of rsips
11
- VERSION = '0.0.2'
11
+ VERSION = '0.1.0'
12
12
 
13
13
  end
14
14
 
data/lib/rsips/image.rb CHANGED
@@ -3,21 +3,22 @@ module Rsips
3
3
  class Image
4
4
 
5
5
  include Rsips::Sips
6
-
7
- attr_reader :width, :height
8
-
6
+
9
7
  def initialize(img)
10
- @img = img # TODO: strip out blank spaces
11
- @width = get_dimension :width
12
- @height = get_dimension :height
8
+ @img = img
9
+
10
+ properties.each do |k, v|
11
+ instance_variable_set("@#{k}", v)
12
+ instance_eval %{
13
+ def #{k}
14
+ instance_variable_get("@#{k}")
15
+ end
16
+ }
17
+ end
13
18
  end
14
19
 
15
- # TODO: how do you know it's long edge?
16
- # pass in both long and short edges with
17
- # short edge being optional
18
20
  def resize!(long_edge)
19
21
  vertical? ? resample(:height, long_edge) : resample(:width, long_edge)
20
- self
21
22
  end
22
23
 
23
24
  def to_jpg!(compression="default")
@@ -30,11 +31,11 @@ module Rsips
30
31
  end
31
32
 
32
33
  def orientation
33
- @img.vertical? ? 'vertical' : 'horizontal'
34
+ vertical? ? 'vertical' : 'horizontal'
34
35
  end
35
36
 
36
37
  def vertical?
37
- @height > @width
38
+ @pixelHeight.to_i > @pixelWidth.to_i # temporarily coerce here
38
39
  end
39
40
  end
40
41
  end
data/lib/rsips/sips.rb CHANGED
@@ -1,11 +1,11 @@
1
1
  module Rsips::Sips
2
2
 
3
- def resample(dimension, pixels)
4
- sips "--resample#{dimension.capitalize} #{pixels} #{@img}"
3
+ def properties
4
+ Hash[`sips -g all '#{@img}'`.split("\n")[1..-1].map { |i| i.strip.split(": ") }]
5
5
  end
6
-
7
- def get_dimension(dimension)
8
- `sips -g pixel#{dimension.capitalize} #{@img}`.chomp.slice(/\d+$/).to_i
6
+
7
+ def resample(dimension, pixels)
8
+ sips "--resample#{dimension.capitalize} #{pixels} '#{@img}'"
9
9
  end
10
10
 
11
11
  def format(type, options={})
@@ -16,7 +16,7 @@ module Rsips::Sips
16
16
  else type
17
17
  end
18
18
  new_image = replace_ext(@img, new_ext)
19
- sips "-s format #{type} -s formatOptions #{options} #{@img} --out #{new_image}"
19
+ sips "-s format #{type} -s formatOptions #{options} '#{@img}' --out #{new_image}"
20
20
  end
21
21
 
22
22
  private
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rsips
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-12 00:00:00.000000000Z
12
+ date: 2011-08-17 00:00:00.000000000Z
13
13
  dependencies: []
14
14
  description:
15
15
  email: