soveran-lomo 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +38 -0
- data/Rakefile +38 -0
- data/bin/lomo +25 -0
- data/img/mask.png +0 -0
- data/lib/lomo/version.rb +13 -0
- data/lib/lomo.rb +54 -0
- data/test/lomo_test.rb +31 -0
- metadata +59 -0
data/README.markdown
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
# Lomo
|
2
|
+
|
3
|
+
## Description
|
4
|
+
|
5
|
+
Lomify your pictures with ImageMagick from the command line.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
sudo gem install soveran-lomo
|
10
|
+
|
11
|
+
## Usage
|
12
|
+
|
13
|
+
lomo path_to_your_picture.jpg
|
14
|
+
|
15
|
+
## License
|
16
|
+
|
17
|
+
Copyright (c) 2008 Michel Martens
|
18
|
+
|
19
|
+
Permission is hereby granted, free of charge, to any person
|
20
|
+
obtaining a copy of this software and associated documentation
|
21
|
+
files (the "Software"), to deal in the Software without
|
22
|
+
restriction, including without limitation the rights to use,
|
23
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
24
|
+
copies of the Software, and to permit persons to whom the
|
25
|
+
Software is furnished to do so, subject to the following
|
26
|
+
conditions:
|
27
|
+
|
28
|
+
The above copyright notice and this permission notice shall be
|
29
|
+
included in all copies or substantial portions of the Software.
|
30
|
+
|
31
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
32
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
33
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
34
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
35
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
36
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
37
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
38
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake/gempackagetask'
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
require 'lib/lomo/version'
|
6
|
+
|
7
|
+
task :default => :test
|
8
|
+
|
9
|
+
spec = Gem::Specification.new do |s|
|
10
|
+
s.name = 'lomo'
|
11
|
+
s.version = Lomo::Version.to_s
|
12
|
+
s.has_rdoc = true
|
13
|
+
s.extra_rdoc_files = %w(README.markdown)
|
14
|
+
s.summary = "Apply a lomo filter to your pictures from the command line"
|
15
|
+
s.author = 'Michel Martens'
|
16
|
+
s.email = 'michel@soveran.com'
|
17
|
+
s.homepage = 'http://github.com/soveran/lomo'
|
18
|
+
s.files = %w(README.markdown Rakefile) + Dir.glob("{lib,test,img}/**/*")
|
19
|
+
s.bindir = "bin"
|
20
|
+
s.executables = "lomo"
|
21
|
+
end
|
22
|
+
|
23
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
24
|
+
pkg.gem_spec = spec
|
25
|
+
end
|
26
|
+
|
27
|
+
Rake::TestTask.new do |t|
|
28
|
+
t.libs << 'test'
|
29
|
+
t.test_files = FileList["test/**/*_test.rb"]
|
30
|
+
t.verbose = true
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Generate the gemspec to serve this Gem from Github'
|
34
|
+
task :github do
|
35
|
+
file = File.dirname(__FILE__) + "/#{spec.name}.gemspec"
|
36
|
+
File.open(file, 'w') {|f| f << spec.to_ruby }
|
37
|
+
puts "Created gemspec: #{file}"
|
38
|
+
end
|
data/bin/lomo
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
unless file_name = ARGV.first
|
4
|
+
puts <<-eos
|
5
|
+
Usage:
|
6
|
+
lomo path_to_image.jpg
|
7
|
+
|
8
|
+
It will generate a 1024x768 version of the image with
|
9
|
+
the lomo filter applied. ImageMagick is required for this
|
10
|
+
to work.
|
11
|
+
eos
|
12
|
+
exit 1
|
13
|
+
end
|
14
|
+
|
15
|
+
file = File.expand_path(file_name)
|
16
|
+
|
17
|
+
unless File.exists?(file)
|
18
|
+
puts "The file #{file_name} doesn't exist"
|
19
|
+
exit
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rubygems'
|
23
|
+
require 'lomo'
|
24
|
+
|
25
|
+
Lomo.new(file).process
|
data/img/mask.png
ADDED
Binary file
|
data/lib/lomo/version.rb
ADDED
data/lib/lomo.rb
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
class Lomo
|
2
|
+
attr :file
|
3
|
+
attr :dest
|
4
|
+
attr :mask
|
5
|
+
|
6
|
+
def initialize(file)
|
7
|
+
@file = File.expand_path(file)
|
8
|
+
@dest = @file.sub /\.jpg$/i, "-lomo.png"
|
9
|
+
@mask = File.join(File.dirname(__FILE__), "../img/mask.png")
|
10
|
+
|
11
|
+
unless File.exists?(@file)
|
12
|
+
usage
|
13
|
+
exit
|
14
|
+
end
|
15
|
+
|
16
|
+
unless `convert --version`.match /ImageMagick/
|
17
|
+
requirements
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def usage
|
23
|
+
puts <<-eos
|
24
|
+
Usage:
|
25
|
+
lomo path_to_image.jpg
|
26
|
+
|
27
|
+
It will generate a 1024x768 version of the image with
|
28
|
+
the lomo filter applied. ImageMagick is required for this
|
29
|
+
to work.
|
30
|
+
eos
|
31
|
+
end
|
32
|
+
|
33
|
+
def requirements
|
34
|
+
puts <<-eos
|
35
|
+
Requirements:
|
36
|
+
|
37
|
+
This filter makes use of ImageMagick. It runs convert and composite with
|
38
|
+
different parameters, so it won't work unless those commands are available.
|
39
|
+
eos
|
40
|
+
end
|
41
|
+
|
42
|
+
def process
|
43
|
+
`cp #{file} #{dest}`
|
44
|
+
`convert -resize 1024x768 #{dest} #{dest}`
|
45
|
+
`cp #{dest} #{dest}-resized`
|
46
|
+
`convert -unsharp 1 #{dest} #{dest}`
|
47
|
+
`convert -contrast -contrast #{dest} #{dest}`
|
48
|
+
`convert -modulate 100,150 #{dest} #{dest}`
|
49
|
+
`composite -compose overlay #{mask} #{dest} #{dest}`
|
50
|
+
`composite -compose multiply #{dest}-resized #{dest} #{dest}`
|
51
|
+
`rm #{dest}-resized`
|
52
|
+
`open #{dest}` if RUBY_PLATFORM.match /darwin/
|
53
|
+
end
|
54
|
+
end
|
data/test/lomo_test.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'rubygems'
|
3
|
+
require 'shoulda'
|
4
|
+
require 'rr'
|
5
|
+
|
6
|
+
require File.join(File.dirname(__FILE__), '../lib/lomo')
|
7
|
+
|
8
|
+
class TestLomo < Test::Unit::TestCase
|
9
|
+
include RR::Adapters::TestUnit
|
10
|
+
|
11
|
+
context "#new" do
|
12
|
+
setup do
|
13
|
+
mock(File).exists?(File.expand_path('file_name.jpg')) { true }
|
14
|
+
end
|
15
|
+
|
16
|
+
should "return an instance of Lomo" do
|
17
|
+
assert_kind_of Lomo, Lomo.new('file_name.jpg')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "lomo" do
|
22
|
+
setup do
|
23
|
+
mock(File).exists?(File.expand_path('file_name.jpg')) { true }
|
24
|
+
@lomo = Lomo.new('file_name.jpg')
|
25
|
+
end
|
26
|
+
|
27
|
+
should "return a file name with -lomo.png as part of the name" do
|
28
|
+
assert_match /-lomo.png$/, @lomo.dest
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
metadata
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: soveran-lomo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michel Martens
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-12-08 00:00:00 -08:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description:
|
17
|
+
email: michel@soveran.com
|
18
|
+
executables:
|
19
|
+
- lomo
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.markdown
|
24
|
+
files:
|
25
|
+
- README.markdown
|
26
|
+
- Rakefile
|
27
|
+
- lib/lomo
|
28
|
+
- lib/lomo/version.rb
|
29
|
+
- lib/lomo.rb
|
30
|
+
- test/lomo_test.rb
|
31
|
+
- img/mask.png
|
32
|
+
has_rdoc: true
|
33
|
+
homepage: http://github.com/soveran/lomo
|
34
|
+
post_install_message:
|
35
|
+
rdoc_options: []
|
36
|
+
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: "0"
|
50
|
+
version:
|
51
|
+
requirements: []
|
52
|
+
|
53
|
+
rubyforge_project:
|
54
|
+
rubygems_version: 1.2.0
|
55
|
+
signing_key:
|
56
|
+
specification_version: 2
|
57
|
+
summary: Apply a lomo filter to your pictures from the command line.
|
58
|
+
test_files: []
|
59
|
+
|