carrierwave-processing 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 +18 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +44 -0
- data/Rakefile +2 -0
- data/carrierwave-processing.gemspec +19 -0
- data/lib/carrierwave-processing.rb +8 -0
- data/lib/carrierwave-processing/mini_magick.rb +23 -0
- data/lib/carrierwave-processing/rmagick.rb +23 -0
- data/lib/carrierwave-processing/version.rb +5 -0
- metadata +71 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Pavel Forkert
|
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,44 @@
|
|
1
|
+
# CarrierWave::Processing
|
2
|
+
|
3
|
+
Additional processing support for MiniMagick and RMagick. These are processors that I've been using in multiple projects so I decided to extract those as a gem.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'carrierwave-processing'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install carrierwave-processing
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
This gem add several useful methods to CarrierWave processing RMagick and MiniMagick modules: `quality` and `strip`.
|
22
|
+
To use those, you should include specified module (RMagick or MiniMagick) into your uploader and use processors:
|
23
|
+
|
24
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
25
|
+
include CarrierWave::RMagick
|
26
|
+
include CarrierWave::Processing::RMagick
|
27
|
+
|
28
|
+
process :strip # strip image of all profiles and comments
|
29
|
+
process :resize_to_fill => [200, 200]
|
30
|
+
process :quality => 90 # Set JPEG/MIFF/PNG compression level (0-100)
|
31
|
+
process :convert => 'png'
|
32
|
+
|
33
|
+
def filename
|
34
|
+
super.chomp(File.extname(super)) + '.png'
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
## Contributing
|
39
|
+
|
40
|
+
1. Fork it
|
41
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
42
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
43
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
44
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/carrierwave-processing/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Pavel Forkert"]
|
6
|
+
gem.email = ["fxposter@gmail.com"]
|
7
|
+
gem.description = %q{Additional processing support for MiniMagick and RMagick}
|
8
|
+
gem.summary = %q{Additional processing support for MiniMagick and RMagick}
|
9
|
+
gem.homepage = "https://github.com/fxposter/carrierwave-processing"
|
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-processing"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = CarrierWave::Processing::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency 'carrierwave'
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CarrierWave
|
2
|
+
module Processing
|
3
|
+
module MiniMagick
|
4
|
+
# Strips out all embedded information from the image
|
5
|
+
def strip
|
6
|
+
manipulate! do |img|
|
7
|
+
img.strip
|
8
|
+
img = yield(img) if block_given?
|
9
|
+
img
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Reduces the quality of the image to the percentage given
|
14
|
+
def quality(percentage)
|
15
|
+
manipulate! do |img|
|
16
|
+
img.quality(percentage.to_s)
|
17
|
+
img = yield(img) if block_given?
|
18
|
+
img
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module CarrierWave
|
2
|
+
module Processing
|
3
|
+
module RMagick
|
4
|
+
# Strips out all embedded information from the image
|
5
|
+
def strip
|
6
|
+
manipulate! do |img|
|
7
|
+
img.strip!
|
8
|
+
img = yield(img) if block_given?
|
9
|
+
img
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Reduces the quality of the image to the percentage given
|
14
|
+
def quality(percentage)
|
15
|
+
manipulate! do |img|
|
16
|
+
img.write(current_path){ self.quality = percentage }
|
17
|
+
img = yield(img) if block_given?
|
18
|
+
img
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,71 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: carrierwave-processing
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Pavel Forkert
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-17 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
|
+
description: Additional processing support for MiniMagick and RMagick
|
31
|
+
email:
|
32
|
+
- fxposter@gmail.com
|
33
|
+
executables: []
|
34
|
+
extensions: []
|
35
|
+
extra_rdoc_files: []
|
36
|
+
files:
|
37
|
+
- .gitignore
|
38
|
+
- Gemfile
|
39
|
+
- LICENSE
|
40
|
+
- README.md
|
41
|
+
- Rakefile
|
42
|
+
- carrierwave-processing.gemspec
|
43
|
+
- lib/carrierwave-processing.rb
|
44
|
+
- lib/carrierwave-processing/mini_magick.rb
|
45
|
+
- lib/carrierwave-processing/rmagick.rb
|
46
|
+
- lib/carrierwave-processing/version.rb
|
47
|
+
homepage: https://github.com/fxposter/carrierwave-processing
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.24
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: Additional processing support for MiniMagick and RMagick
|
71
|
+
test_files: []
|