jekyll-smartcropper 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +35 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +50 -0
- data/LICENSE +22 -0
- data/README.md +47 -0
- data/Rakefile +2 -0
- data/jekyll-smartcropper.gemspec +25 -0
- data/lib/jekyll-smartcropper/version.rb +5 -0
- data/lib/jekyll-smartcropper.rb +73 -0
- metadata +95 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 5e8f3dd32fa8a4344f2700b68789aafad0a08594
|
4
|
+
data.tar.gz: 0f105c42c31161c3d324a769400b281ad5b404b5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7ddbba629272929862d12edaba1ae91b242ea13e1e392b228b579d2f4fd2aa7d03686a85fde5781d7d7a79242952c4d051ed00119c5a25989c19fbc29cb0cf4e
|
7
|
+
data.tar.gz: 2f2452a4e25515bb4279f92e6dd1c0ad067ffb978a0db74ed6ccde2dd90c34b06079e7d53c36d0c663dc923fe8774b25b6d0a64fb00fbc88f984304434d2ccdb
|
data/.gitignore
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/vendor/bundle
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
# Gemfile.lock
|
31
|
+
# .ruby-version
|
32
|
+
# .ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jekyll-smartcropper (0.0.1)
|
5
|
+
jekyll (>= 3.0.0)
|
6
|
+
rmagick (> 2.11.0)
|
7
|
+
smartcropper (>= 0.7.1)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: http://rubygems.org/
|
11
|
+
specs:
|
12
|
+
colorator (0.1)
|
13
|
+
ffi (1.9.10)
|
14
|
+
jekyll (3.0.0)
|
15
|
+
colorator (~> 0.1)
|
16
|
+
jekyll-sass-converter (~> 1.0)
|
17
|
+
jekyll-watch (~> 1.1)
|
18
|
+
kramdown (~> 1.3)
|
19
|
+
liquid (~> 3.0)
|
20
|
+
mercenary (~> 0.3.3)
|
21
|
+
rouge (~> 1.7)
|
22
|
+
safe_yaml (~> 1.0)
|
23
|
+
jekyll-sass-converter (1.3.0)
|
24
|
+
sass (~> 3.2)
|
25
|
+
jekyll-watch (1.3.0)
|
26
|
+
listen (~> 3.0)
|
27
|
+
kramdown (1.9.0)
|
28
|
+
liquid (3.0.6)
|
29
|
+
listen (3.0.4)
|
30
|
+
rb-fsevent (>= 0.9.3)
|
31
|
+
rb-inotify (>= 0.9)
|
32
|
+
mercenary (0.3.5)
|
33
|
+
rb-fsevent (0.9.6)
|
34
|
+
rb-inotify (0.9.5)
|
35
|
+
ffi (>= 0.5.0)
|
36
|
+
rmagick (2.15.4)
|
37
|
+
rouge (1.10.1)
|
38
|
+
safe_yaml (1.0.4)
|
39
|
+
sass (3.4.19)
|
40
|
+
smartcropper (0.7.1)
|
41
|
+
rmagick (> 2.11.0)
|
42
|
+
|
43
|
+
PLATFORMS
|
44
|
+
ruby
|
45
|
+
|
46
|
+
DEPENDENCIES
|
47
|
+
jekyll-smartcropper!
|
48
|
+
|
49
|
+
BUNDLED WITH
|
50
|
+
1.10.6
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Josh Gerdes
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
Smartcropper Image Generator for Jekyll
|
2
|
+
=================================
|
3
|
+
|
4
|
+
This gem allows you to easily use [SmartCropper](http://berk.es/smartcropper/) and [RMagick](https://github.com/rmagick/rmagick) to crop and resize images in your Jekyll project, according to a preset defined in your config file.
|
5
|
+
|
6
|
+
Basic Setup
|
7
|
+
-----------
|
8
|
+
Install the gem:
|
9
|
+
|
10
|
+
[sudo] gem install jekyll-smartcropper
|
11
|
+
|
12
|
+
In a plugin file within your Jekyll project's _plugins directory:
|
13
|
+
|
14
|
+
# _plugins/my-plugin.rb
|
15
|
+
require "jekyll-smartcropper"
|
16
|
+
|
17
|
+
Define presets in your _config.yml file, like this:
|
18
|
+
|
19
|
+
# _config.yml
|
20
|
+
smartcropper:
|
21
|
+
thumbnail:
|
22
|
+
source: img/original
|
23
|
+
destination: img/thumb
|
24
|
+
process: "crop_and_scale"
|
25
|
+
width: 100
|
26
|
+
height: 100
|
27
|
+
medium:
|
28
|
+
source: img/original
|
29
|
+
destination: img/medium
|
30
|
+
process: "crop"
|
31
|
+
width: 600
|
32
|
+
height: 400
|
33
|
+
|
34
|
+
This configuration will create a 100x100 thumbnail for each image in _img/original_ and put it in _\_site/img/photos/thumbnail_ and a 600x400 image in _\_site/img/photos/medium_.
|
35
|
+
|
36
|
+
Bundler Setup
|
37
|
+
-------------
|
38
|
+
Already using bundler to manage gems for your Jekyll project? Then just add
|
39
|
+
|
40
|
+
gem "jekyll-smartcropper"
|
41
|
+
|
42
|
+
to your gemfile and create the following plugin in your projects _plugins directory. I've called mine bundler.rb. This will automatically require all of the gems specified in your Gemfile.
|
43
|
+
|
44
|
+
# _plugins/bundler.rb
|
45
|
+
require "rubygems"
|
46
|
+
require "bundler/setup"
|
47
|
+
Bundler.require(:default)
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "jekyll-smartcropper/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "jekyll-smartcropper"
|
7
|
+
s.version = Jekyll::SmartCropper::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Josh Gerdes"]
|
10
|
+
s.email = ["josh@joshgerdes.com"]
|
11
|
+
s.homepage = "http://github.com/joshgerdes/jekyll-smartcropper"
|
12
|
+
s.summary = %q{Smartcropper Image Generator for Jekyll}
|
13
|
+
s.description = %q{Use smartcropper and rmagick to crop and resize images in your Jekyll project.}
|
14
|
+
|
15
|
+
s.rubyforge_project = "jekyll-smartcropper"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_runtime_dependency('jekyll', [">= 3.0.0"])
|
23
|
+
s.add_runtime_dependency('smartcropper', [">= 0.7.1"])
|
24
|
+
s.add_runtime_dependency('rmagick', ["> 2.11.0"])
|
25
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require "jekyll-smartcropper/version"
|
2
|
+
require 'smartcropper'
|
3
|
+
require 'RMagick'
|
4
|
+
|
5
|
+
include Magick
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
module Jekyll
|
9
|
+
module SmartCropper
|
10
|
+
# This part is copied from https://github.com/kinnetica/jekyll-plugins
|
11
|
+
# Recover from strange exception when starting server without --auto
|
12
|
+
class GeneratedImageFile < StaticFile
|
13
|
+
def write(dest)
|
14
|
+
begin
|
15
|
+
super(dest)
|
16
|
+
rescue
|
17
|
+
end
|
18
|
+
true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class ImageGenerator < Generator
|
23
|
+
def generate(site)
|
24
|
+
return unless site.config['smartcropper']
|
25
|
+
|
26
|
+
print " Starting SmartCropper...\n"
|
27
|
+
|
28
|
+
site.config['smartcropper'].each_pair do |name, preset|
|
29
|
+
print " Generating '" + name + "'\n"
|
30
|
+
|
31
|
+
@dest_dir = preset['destination']
|
32
|
+
@src_dir = preset['source']
|
33
|
+
@process = preset['process']
|
34
|
+
@width = preset['width']
|
35
|
+
@height = preset['height']
|
36
|
+
|
37
|
+
Dir.glob(File.join(site.source, @src_dir, "*.{png,jpg,jpeg,gif}")) do |file|
|
38
|
+
dest_file = file.sub(@src_dir, @dest_dir)
|
39
|
+
|
40
|
+
FileUtils.mkdir_p(File.dirname(dest_file))
|
41
|
+
|
42
|
+
puts case @process
|
43
|
+
when "crop_and_scale"
|
44
|
+
SmartCropper.from_file(file).smart_crop_and_scale(@width, @height).write(dest_file)
|
45
|
+
when "crop"
|
46
|
+
SmartCropper.from_file(file).smart_crop(@width, @height).write(dest_file)
|
47
|
+
when "square"
|
48
|
+
SmartCropper.from_file(file).smart_square.write(dest_file)
|
49
|
+
when "resize"
|
50
|
+
img = Magick::Image.read(file).first
|
51
|
+
new_img = img.resize(@width, @height)
|
52
|
+
new_img.write dest_file
|
53
|
+
when "resize_to_fill"
|
54
|
+
img = Magick::Image.read(file).first
|
55
|
+
new_img = img.resize_to_fill(@width, @height)
|
56
|
+
new_img.write dest_file
|
57
|
+
when "resize_to_fit"
|
58
|
+
img = Magick::Image.read(file).first
|
59
|
+
new_img = img.resize_to_fit(@width, @height)
|
60
|
+
new_img.write dest_file
|
61
|
+
else
|
62
|
+
img = Magick::Image.read(file).first
|
63
|
+
new_img = img.resize(@width, @height)
|
64
|
+
new_img.write dest_file
|
65
|
+
end
|
66
|
+
|
67
|
+
site.static_files << GeneratedImageFile.new(site, site.source, @dest_dir, File.basename(dest_file))
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jekyll-smartcropper
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Josh Gerdes
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: jekyll
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 3.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 3.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: smartcropper
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 0.7.1
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 0.7.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rmagick
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>'
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 2.11.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>'
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 2.11.0
|
55
|
+
description: Use smartcropper and rmagick to crop and resize images in your Jekyll
|
56
|
+
project.
|
57
|
+
email:
|
58
|
+
- josh@joshgerdes.com
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- .gitignore
|
64
|
+
- Gemfile
|
65
|
+
- Gemfile.lock
|
66
|
+
- LICENSE
|
67
|
+
- README.md
|
68
|
+
- Rakefile
|
69
|
+
- jekyll-smartcropper.gemspec
|
70
|
+
- lib/jekyll-smartcropper.rb
|
71
|
+
- lib/jekyll-smartcropper/version.rb
|
72
|
+
homepage: http://github.com/joshgerdes/jekyll-smartcropper
|
73
|
+
licenses: []
|
74
|
+
metadata: {}
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options: []
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - '>='
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '0'
|
84
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - '>='
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '0'
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project: jekyll-smartcropper
|
91
|
+
rubygems_version: 2.5.0
|
92
|
+
signing_key:
|
93
|
+
specification_version: 4
|
94
|
+
summary: Smartcropper Image Generator for Jekyll
|
95
|
+
test_files: []
|