dragonfly_libvips 2.0.1 → 2.1.0
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -2
- data/CHANGELOG.md +4 -0
- data/dragonfly_libvips.gemspec +1 -1
- data/lib/dragonfly_libvips/analysers/image_properties.rb +5 -2
- data/lib/dragonfly_libvips/processors/thumb.rb +32 -18
- data/lib/dragonfly_libvips/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06644e1c4dec0b4e785390a7414522c662018bcc
|
4
|
+
data.tar.gz: aaf43c2978f8a87992d0ccc13bf689a1f3b3a02f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 670f2d8d7b42eaa5246496000cfafa31fb44e761fe1e643d883dbbaef5a723fc35ad522a864657e17a80ef1978601fae96570af0cb693543cd1a0d962de3bdbc
|
7
|
+
data.tar.gz: c84c9cf19b33c3b4b4c2cfa07670f51587b51e6e28cdd700792d48b6df704f0cad51473ec0bea240d356c6f4d7b4c51b197c34be21e42349c275db4ca7043403
|
data/.travis.yml
CHANGED
@@ -11,8 +11,8 @@ before_install:
|
|
11
11
|
- gem install bundler -v 1.12.5
|
12
12
|
- sudo apt-get update
|
13
13
|
- sudo apt-get install -y gobject-introspection libgirepository1.0-dev libglib2.0-dev libpoppler-glib-dev
|
14
|
-
- curl -
|
15
|
-
- tar zvxf vips-8.
|
14
|
+
- curl -OL https://github.com/jcupitt/libvips/releases/download/v8.5.8/vips-8.5.8.tar.gz
|
15
|
+
- tar zvxf vips-8.5.8.tar.gz && cd vips-8.5.8 && ./configure && sudo make && sudo make install
|
16
16
|
- export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0/
|
17
17
|
- sudo ldconfig
|
18
18
|
|
data/CHANGELOG.md
CHANGED
data/dragonfly_libvips.gemspec
CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
21
|
spec.add_dependency 'dragonfly', '~> 1.0'
|
22
|
-
spec.add_dependency 'ruby-vips', '~> 2.0', '>= 2.0.
|
22
|
+
spec.add_dependency 'ruby-vips', '~> 2.0', '>= 2.0.6'
|
23
23
|
spec.add_dependency 'activesupport', '>= 4.0'
|
24
24
|
|
25
25
|
spec.add_development_dependency 'bundler', '~> 1.12'
|
@@ -1,12 +1,15 @@
|
|
1
|
+
require 'vips'
|
2
|
+
|
1
3
|
module DragonflyLibvips
|
2
4
|
module Analysers
|
3
5
|
class ImageProperties
|
4
|
-
|
5
|
-
require 'vips'
|
6
|
+
DPI = 300
|
6
7
|
|
8
|
+
def call(content)
|
7
9
|
input_options = {}
|
8
10
|
input_options[:access] = :sequential
|
9
11
|
input_options[:autorotate] = true if content.mime_type == 'image/jpeg'
|
12
|
+
input_options[:dpi] = DPI if content.mime_type == 'application/pdf'
|
10
13
|
|
11
14
|
img = ::Vips::Image.new_from_file(content.path, input_options)
|
12
15
|
|
@@ -7,42 +7,56 @@ module DragonflyLibvips
|
|
7
7
|
class Thumb
|
8
8
|
OPERATORS = '><'.freeze
|
9
9
|
RESIZE_GEOMETRY = /\A\d*x\d*[#{OPERATORS}]?\z/ # e.g. '300x200>'
|
10
|
-
|
10
|
+
DPI = 300
|
11
11
|
|
12
12
|
def call(content, geometry, options = {})
|
13
|
-
options = options.
|
13
|
+
options = options.deep_symbolize_keys
|
14
14
|
|
15
|
-
|
15
|
+
filename = content.path
|
16
|
+
format = options.fetch(:format, content.ext)
|
16
17
|
|
17
|
-
input_options = options.fetch(
|
18
|
-
|
19
|
-
|
18
|
+
input_options = options.fetch(:input_options, {})
|
19
|
+
input_options[:access] = input_options.fetch(:access, 'sequential')
|
20
|
+
input_options[:autorotate] = input_options.fetch(:autorotate, true) if content.mime_type == 'image/jpeg'
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
input_options[
|
22
|
+
if content.mime_type == 'application/pdf'
|
23
|
+
input_options[:dpi] = input_options.fetch(:dpi, DPI) if content.mime_type == 'application/pdf'
|
24
|
+
input_options[:page] = input_options.fetch(:page, 0) if content.mime_type == 'application/pdf'
|
25
|
+
else
|
26
|
+
input_options.delete(:page)
|
27
|
+
input_options.delete(:dpi)
|
24
28
|
end
|
25
|
-
output_options['profile'] ||= DragonflyLibvips::EPROFILE_PATH
|
26
29
|
|
27
|
-
|
30
|
+
output_options = options.fetch(:output_options, {})
|
31
|
+
output_options[:profile] = input_options.fetch(:profile, DragonflyLibvips::EPROFILE_PATH)
|
32
|
+
|
33
|
+
img = ::Vips::Image.new_from_file(filename, input_options)
|
28
34
|
|
29
35
|
dimensions = case geometry
|
30
|
-
|
31
|
-
else raise ArgumentError, "Didn't recognise the geometry string #{geometry}"
|
36
|
+
when RESIZE_GEOMETRY then DragonflyLibvips::Dimensions.call(geometry, img.width, img.height)
|
37
|
+
else raise ArgumentError, "Didn't recognise the geometry string: #{geometry}"
|
32
38
|
end
|
33
39
|
|
34
|
-
|
35
|
-
|
40
|
+
thumbnail_options = options.fetch(:thumbnail_options, {})
|
41
|
+
thumbnail_options[:auto_rotate] = input_options.fetch(:autorotate, true) if content.mime_type == 'image/jpeg'
|
42
|
+
thumbnail_options[:height] = thumbnail_options.fetch(:height, dimensions.height.ceil)
|
43
|
+
thumbnail_options[:size] ||= case geometry
|
44
|
+
when />\z/ then :down # do_not_resize_if_image_smaller_than_requested
|
45
|
+
when /<\z/ then :up # do_not_resize_if_image_larger_than_requested
|
46
|
+
else :both
|
36
47
|
end
|
37
48
|
|
38
|
-
|
49
|
+
filename += "[page=#{input_options[:page]}]" if content.mime_type == 'application/pdf'
|
50
|
+
thumb = ::Vips::Image.thumbnail(filename, dimensions.width.ceil, thumbnail_options)
|
51
|
+
|
52
|
+
content.update(thumb.write_to_buffer(".#{format}", output_options), 'format' => format)
|
39
53
|
content.ext = format
|
40
54
|
end
|
41
55
|
|
42
56
|
def update_url(url_attributes, _, options = {})
|
43
|
-
options = options.
|
57
|
+
options = options.deep_symbolize_keys
|
44
58
|
|
45
|
-
if format = options.fetch(
|
59
|
+
if format = options.fetch(:format, nil)
|
46
60
|
url_attributes.ext = format
|
47
61
|
end
|
48
62
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dragonfly_libvips
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0
|
4
|
+
version: 2.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tomas Celizna
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dragonfly
|
@@ -33,7 +33,7 @@ dependencies:
|
|
33
33
|
version: '2.0'
|
34
34
|
- - ">="
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 2.0.
|
36
|
+
version: 2.0.6
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -43,7 +43,7 @@ dependencies:
|
|
43
43
|
version: '2.0'
|
44
44
|
- - ">="
|
45
45
|
- !ruby/object:Gem::Version
|
46
|
-
version: 2.0.
|
46
|
+
version: 2.0.6
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: activesupport
|
49
49
|
requirement: !ruby/object:Gem::Requirement
|