carrierwave_imagevoodoo 0.0.3-java
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +35 -0
- data/Rakefile +9 -0
- data/carrierwave_imagevoodoo.gemspec +23 -0
- data/lib/carrierwave_imagevoodoo/version.rb +5 -0
- data/lib/carrierwave_imagevoodoo.rb +80 -0
- metadata +101 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Tasveer Singh
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# CarrierWave ImageVoodoo
|
2
|
+
|
3
|
+
CarrierWave support for ImageVoodoo
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'carrierwave_imagevoodoo'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install carrierwave_imagevoodoo
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
Simply include `CarrierWave::ImageVoodoo` in your CarrierWave Uploader:
|
22
|
+
|
23
|
+
class MyUploader < CarrierWave::Uploader::Base
|
24
|
+
include CarrierWave::ImageVoodoo
|
25
|
+
|
26
|
+
# do some processing...
|
27
|
+
end
|
28
|
+
|
29
|
+
## Contributing
|
30
|
+
|
31
|
+
1. Fork it
|
32
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
33
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
34
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
35
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/carrierwave_imagevoodoo/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Tasveer Singh"]
|
6
|
+
gem.email = ["taz@zenapsis.com"]
|
7
|
+
gem.description = "CarrierWave support for ImageVoodoo"
|
8
|
+
gem.summary = "A simple CarrierWave processor utilizing ImageVoodoo for processing"
|
9
|
+
gem.homepage = "https://github.com/zenapsis/carrierwave_imagevoodoo"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "carrierwave_imagevoodoo"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = CarrierWave::ImageVoodoo::VERSION
|
17
|
+
gem.platform = "java"
|
18
|
+
|
19
|
+
gem.add_dependency "carrierwave"
|
20
|
+
gem.add_dependency "image_voodoo"
|
21
|
+
|
22
|
+
gem.add_development_dependency "rake"
|
23
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require "carrierwave_imagevoodoo/version"
|
2
|
+
|
3
|
+
module CarrierWave
|
4
|
+
module ImageVoodoo
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
module ClassMethods
|
8
|
+
def convert format
|
9
|
+
process :convert => format
|
10
|
+
end
|
11
|
+
|
12
|
+
#def resize_to_limit width, height
|
13
|
+
# process :resize_to_limit => [width, height]
|
14
|
+
#end
|
15
|
+
|
16
|
+
def resize_to_fit width, height
|
17
|
+
process :resize_to_fit => [width, height]
|
18
|
+
end
|
19
|
+
|
20
|
+
def resize_to_fill width, height
|
21
|
+
process :resize_to_fill => [width, height]
|
22
|
+
end
|
23
|
+
|
24
|
+
#def resize_and_pad width, height, background = :transparent
|
25
|
+
# process :resize_and_pad => [width, height, background]
|
26
|
+
#end
|
27
|
+
end
|
28
|
+
|
29
|
+
def convert format
|
30
|
+
manipulate! do |image|
|
31
|
+
yield(image) if block_given?
|
32
|
+
image.save "#{current_path.chomp(File.extname(f))}.#{format}"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
#def resize_to_limit width, height
|
37
|
+
#end
|
38
|
+
|
39
|
+
def resize_to_fit width, height
|
40
|
+
manipulate! do |image|
|
41
|
+
cols = image.width
|
42
|
+
rows = image.height
|
43
|
+
|
44
|
+
if width != cols or height != rows
|
45
|
+
scale = [width/cols.to_f, height/rows.to_f].min
|
46
|
+
cols = (scale * (cols + 0.5)).round
|
47
|
+
rows = (scale * (rows + 0.5)).round
|
48
|
+
image.resize cols, rows do |img|
|
49
|
+
yield(img) if block_given?
|
50
|
+
img.save current_path
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def resize_to_fill width, height
|
57
|
+
manipulate! do |image|
|
58
|
+
cols = image.width
|
59
|
+
rows = image.height
|
60
|
+
|
61
|
+
if width != cols or height != rows
|
62
|
+
scale = [width/cols.to_f, height/rows.to_f].max
|
63
|
+
cols = (scale * (cols + 0.5)).round
|
64
|
+
rows = (scale * (rows + 0.5)).round
|
65
|
+
image.resize cols, rows do |img|
|
66
|
+
yield(img) if block_given?
|
67
|
+
img.save current_path
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
#def resize_and_pad width, height, background = :transparent
|
74
|
+
#end
|
75
|
+
|
76
|
+
def manipulate!
|
77
|
+
yield ::ImageVoodoo.with_bytes file.read
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
metadata
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carrierwave_imagevoodoo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
prerelease:
|
6
|
+
platform: java
|
7
|
+
authors:
|
8
|
+
- Tasveer Singh
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-14 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: carrierwave
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: image_voodoo
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rake
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
description: CarrierWave support for ImageVoodoo
|
63
|
+
email:
|
64
|
+
- taz@zenapsis.com
|
65
|
+
executables: []
|
66
|
+
extensions: []
|
67
|
+
extra_rdoc_files: []
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- Gemfile
|
71
|
+
- LICENSE
|
72
|
+
- README.md
|
73
|
+
- Rakefile
|
74
|
+
- carrierwave_imagevoodoo.gemspec
|
75
|
+
- lib/carrierwave_imagevoodoo.rb
|
76
|
+
- lib/carrierwave_imagevoodoo/version.rb
|
77
|
+
homepage: https://github.com/zenapsis/carrierwave_imagevoodoo
|
78
|
+
licenses: []
|
79
|
+
post_install_message:
|
80
|
+
rdoc_options: []
|
81
|
+
require_paths:
|
82
|
+
- lib
|
83
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
none: false
|
85
|
+
requirements:
|
86
|
+
- - ! '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: '0'
|
95
|
+
requirements: []
|
96
|
+
rubyforge_project:
|
97
|
+
rubygems_version: 1.8.21
|
98
|
+
signing_key:
|
99
|
+
specification_version: 3
|
100
|
+
summary: A simple CarrierWave processor utilizing ImageVoodoo for processing
|
101
|
+
test_files: []
|