paperclip-vips 1.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/Gemfile.lock +4 -2
- data/lib/paperclip-vips/paperclip/vips.rb +53 -42
- data/lib/paperclip-vips/version.rb +1 -1
- data/paperclip-vips.gemspec +1 -0
- metadata +16 -3
- data/paperclip-vips-1.0.0.gem +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25b4601f012a9e1916a415fb83af8ea29e4f5d0a1a961bdd2a8780fb9eb09891
|
4
|
+
data.tar.gz: 07e04b8e2b8de1bdef06679ccfd759a1e13d88ad7c5a739710c9903e857297e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78c286fd9428cee69a9c9e87edf2808e45eebd611f1e87e2cb48bb0f554548d82c1ddfd78dcaffc6de621cae4095bbdf257327cf0dc7330dc741169f36d2d16e
|
7
|
+
data.tar.gz: 8e1349c141065d91940c6ef4b504ea9bfd8e11dcf139f73b92304e9f8ca55436e43346bc8301e24f1d63a00e34590b48a881d799ce4740d0bf8e27808204f2fe
|
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
paperclip-vips (1.
|
5
|
-
paperclip (>= 5.
|
4
|
+
paperclip-vips (1.1.0)
|
5
|
+
paperclip (>= 5.0.0)
|
6
6
|
ruby-vips (~> 2.0.13)
|
7
7
|
|
8
8
|
GEM
|
@@ -15,6 +15,7 @@ GEM
|
|
15
15
|
i18n (>= 0.7, < 2)
|
16
16
|
minitest (~> 5.1)
|
17
17
|
tzinfo (~> 1.1)
|
18
|
+
byebug (11.0.1)
|
18
19
|
climate_control (0.2.0)
|
19
20
|
concurrent-ruby (1.1.5)
|
20
21
|
diff-lcs (1.3)
|
@@ -59,6 +60,7 @@ PLATFORMS
|
|
59
60
|
|
60
61
|
DEPENDENCIES
|
61
62
|
bundler (~> 2.0)
|
63
|
+
byebug (~> 11.0)
|
62
64
|
paperclip-vips!
|
63
65
|
rake (~> 10.0)
|
64
66
|
rspec (~> 3.0)
|
@@ -12,20 +12,12 @@ module Paperclip
|
|
12
12
|
@current_geometry = options.fetch(:file_geometry_parser, Geometry).from_file(@file)
|
13
13
|
@whiny = options.fetch(:whiny, true)
|
14
14
|
|
15
|
-
@current_format =
|
15
|
+
@current_format = current_format(file).downcase
|
16
16
|
@format = options[:format] || @current_format
|
17
17
|
|
18
18
|
@basename = File.basename(@file.path, @current_format)
|
19
19
|
end
|
20
20
|
|
21
|
-
def crop
|
22
|
-
if @should_crop
|
23
|
-
return @options[:crop] || :centre
|
24
|
-
end
|
25
|
-
|
26
|
-
nil
|
27
|
-
end
|
28
|
-
|
29
21
|
def make
|
30
22
|
source = @file
|
31
23
|
filename = [@basename, @format ? ".#{@format}" : ""].join
|
@@ -47,46 +39,65 @@ module Paperclip
|
|
47
39
|
return destination
|
48
40
|
end
|
49
41
|
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
def height
|
55
|
-
@target_geometry&.height || @current_geometry.height
|
56
|
-
end
|
57
|
-
|
58
|
-
def process_convert_options(image)
|
59
|
-
if image && @options[:convert_options].present?
|
60
|
-
commands = JSON.parse(@options[:convert_options], symbolize_names: true)
|
61
|
-
commands.each do |cmd|
|
62
|
-
image = ::Vips::Operation.call(cmd[:cmd], [image, *cmd[:args]], cmd[:optional] || {})
|
42
|
+
private
|
43
|
+
def crop
|
44
|
+
if @should_crop
|
45
|
+
return @options[:crop] || :centre
|
63
46
|
end
|
47
|
+
|
48
|
+
nil
|
64
49
|
end
|
65
50
|
|
66
|
-
|
67
|
-
|
51
|
+
def current_format(file)
|
52
|
+
extension = File.extname(file.path)
|
53
|
+
return extension if extension.present?
|
68
54
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
when ".gif"
|
74
|
-
save_gif(thumbnail, path)
|
75
|
-
when ".png"
|
76
|
-
save_png(thumbnail, path)
|
55
|
+
extension = File.extname(file.original_filename)
|
56
|
+
return extension if extension.present?
|
57
|
+
|
58
|
+
return ""
|
77
59
|
end
|
78
|
-
end
|
79
60
|
|
80
|
-
|
81
|
-
|
82
|
-
|
61
|
+
def width
|
62
|
+
@target_geometry&.width || @current_geometry.width
|
63
|
+
end
|
83
64
|
|
84
|
-
|
85
|
-
|
86
|
-
|
65
|
+
def height
|
66
|
+
@target_geometry&.height || @current_geometry.height
|
67
|
+
end
|
68
|
+
|
69
|
+
def process_convert_options(image)
|
70
|
+
if image && @options[:convert_options].present?
|
71
|
+
commands = JSON.parse(@options[:convert_options], symbolize_names: true)
|
72
|
+
commands.each do |cmd|
|
73
|
+
image = ::Vips::Operation.call(cmd[:cmd], [image, *cmd[:args]], cmd[:optional] || {})
|
74
|
+
end
|
75
|
+
end
|
87
76
|
|
88
|
-
|
89
|
-
|
90
|
-
|
77
|
+
return image
|
78
|
+
end
|
79
|
+
|
80
|
+
def save_thumbnail(thumbnail, path)
|
81
|
+
case @current_format
|
82
|
+
when ".jpeg", ".jpg"
|
83
|
+
save_jpg(thumbnail, path)
|
84
|
+
when ".gif"
|
85
|
+
save_gif(thumbnail, path)
|
86
|
+
when ".png"
|
87
|
+
save_png(thumbnail, path)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def save_jpg(thumbnail, path)
|
92
|
+
thumbnail.jpegsave(path)
|
93
|
+
end
|
94
|
+
|
95
|
+
def save_gif(thumbnail, path)
|
96
|
+
thumbnail.magicksave(path)
|
97
|
+
end
|
98
|
+
|
99
|
+
def save_png(thumbnail, path)
|
100
|
+
thumbnail.pngsave(path)
|
101
|
+
end
|
91
102
|
end
|
92
103
|
end
|
data/paperclip-vips.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-vips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Greeff
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-06-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: paperclip
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '11.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '11.0'
|
83
97
|
description:
|
84
98
|
email:
|
85
99
|
- ken@kengreeff.com
|
@@ -101,7 +115,6 @@ files:
|
|
101
115
|
- lib/paperclip-vips.rb
|
102
116
|
- lib/paperclip-vips/paperclip/vips.rb
|
103
117
|
- lib/paperclip-vips/version.rb
|
104
|
-
- paperclip-vips-1.0.0.gem
|
105
118
|
- paperclip-vips.gemspec
|
106
119
|
homepage: https://github.com/realhub/paperclip-vips
|
107
120
|
licenses:
|
data/paperclip-vips-1.0.0.gem
DELETED
Binary file
|