dragonfly_libvips 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.travis.yml +39 -0
- data/CHANGELOG.md +0 -0
- data/Gemfile +4 -0
- data/Guardfile +8 -0
- data/LICENSE.txt +21 -0
- data/README.md +156 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/dragonfly_libvips.gemspec +28 -0
- data/lib/dragonfly_libvips/analysers/image_properties.rb +22 -0
- data/lib/dragonfly_libvips/plugin.rb +78 -0
- data/lib/dragonfly_libvips/processors/encode.rb +14 -0
- data/lib/dragonfly_libvips/processors/thumb.rb +53 -0
- data/lib/dragonfly_libvips/processors/vips.rb +32 -0
- data/lib/dragonfly_libvips/processors/vipsthumbnail.rb +24 -0
- data/lib/dragonfly_libvips/version.rb +3 -0
- data/lib/dragonfly_libvips.rb +3 -0
- data/samples/beach.png +0 -0
- data/samples/landscape_beach.png +0 -0
- data/samples/memo.pdf +0 -0
- data/samples/white pixel.png +0 -0
- metadata +151 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2eaa493a04d09a02fff56c6ed9a96d244453142d
|
4
|
+
data.tar.gz: ffc53d69657496a3413d6937715f35a3e261225c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6278072c36ef32d7a2b96167b79dec82d92382c41c3aa83586da2b9e4d682a1fd9fdcd82f132b5fc669cba9274d90a488c1c1edc2042df0f99ffb14e09d72545
|
7
|
+
data.tar.gz: 44824ca4a8057952278319e75b84c79546fa41f226fcab7758e58367fcb2b7521433ce6aaf2b07b81f29367ab6d0f9a36746aab659de7ad91b1e52f6e629cd77
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# libvips build instructions taken from https://github.com/marcbachmann/dockerfile-libvips
|
2
|
+
|
3
|
+
language: ruby
|
4
|
+
script: 'bundle exec rake'
|
5
|
+
sudo: required
|
6
|
+
dist: trusty
|
7
|
+
rvm:
|
8
|
+
- 2.2.5
|
9
|
+
env:
|
10
|
+
- LIBVIPS_VERSION_MAJOR=8 LIBVIPS_VERSION_MINOR=3 LIBVIPS_VERSION_PATCH=3 LIBVIPS_VERSION=$LIBVIPS_VERSION_MAJOR.$LIBVIPS_VERSION_MINOR.$LIBVIPS_VERSION_PATCH
|
11
|
+
before_install:
|
12
|
+
- gem install bundler -v 1.12.5
|
13
|
+
|
14
|
+
# Install dependencies
|
15
|
+
- sudo apt-get update
|
16
|
+
- DEBIAN_FRONTEND=noninteractive sudo apt-get install -y automake build-essential curl gobject-introspection gtk-doc-tools libglib2.0-dev libjpeg-turbo8-dev libpng12-dev libwebp-dev libtiff5-dev libexif-dev libxml2-dev swig libpango1.0-dev libmatio-dev libopenslide-dev libcfitsio3-dev
|
17
|
+
- DEBIAN_FRONTEND=noninteractive sudo apt-get install -y libgif-dev librsvg2-dev libpoppler-glib-dev libfftw3-dev liblcms2-dev libpangoft2-1.0-0 liborc-0.4-dev libpoppler-glib-dev
|
18
|
+
|
19
|
+
# Build libvips
|
20
|
+
- curl -O http://www.vips.ecs.soton.ac.uk/supported/$LIBVIPS_VERSION_MAJOR.$LIBVIPS_VERSION_MINOR/vips-$LIBVIPS_VERSION.tar.gz
|
21
|
+
- tar zvxf vips-$LIBVIPS_VERSION.tar.gz && cd vips-$LIBVIPS_VERSION
|
22
|
+
- ./configure $1
|
23
|
+
- sudo make
|
24
|
+
- sudo make install
|
25
|
+
- sudo ldconfig
|
26
|
+
|
27
|
+
# Clean up
|
28
|
+
- sudo apt-get remove -y curl automake build-essential
|
29
|
+
- sudo apt-get autoremove -y
|
30
|
+
- sudo apt-get autoclean
|
31
|
+
- sudo apt-get clean
|
32
|
+
- sudo rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
|
33
|
+
|
34
|
+
notifications:
|
35
|
+
email:
|
36
|
+
recipients:
|
37
|
+
- tomas.celizna@gmail.com
|
38
|
+
on_failure: change
|
39
|
+
on_success: never
|
data/CHANGELOG.md
ADDED
File without changes
|
data/Gemfile
ADDED
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Tomas Celizna
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
# Dragonfly libvips
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/tomasc/dragonfly_libvips.svg)](https://travis-ci.org/tomasc/dragonfly_libvips) [![Gem Version](https://badge.fury.io/rb/dragonfly_libvips.svg)](http://badge.fury.io/rb/dragonfly_libvips) [![Coverage Status](https://img.shields.io/coveralls/tomasc/dragonfly_libvips.svg)](https://coveralls.io/r/tomasc/dragonfly_pdf)
|
4
|
+
|
5
|
+
Dragonfly analysers and processors for [libvips](https://github.com/jcupitt/libvips) image processing library
|
6
|
+
|
7
|
+
From the libvips README:
|
8
|
+
|
9
|
+
> libvips is a 2D image processing library. Compared to similar libraries, [libvips runs quickly and uses little memory](http://www.vips.ecs.soton.ac.uk/index.php?title=Speed_and_Memory_Use). libvips is licensed under the LGPL 2.1+.
|
10
|
+
|
11
|
+
## Installation
|
12
|
+
|
13
|
+
Add this line to your application's Gemfile:
|
14
|
+
|
15
|
+
```ruby
|
16
|
+
gem 'dragonfly_libvips'
|
17
|
+
```
|
18
|
+
|
19
|
+
And then execute:
|
20
|
+
|
21
|
+
```
|
22
|
+
$ bundle
|
23
|
+
```
|
24
|
+
|
25
|
+
Or install it yourself as:
|
26
|
+
|
27
|
+
```
|
28
|
+
$ gem install dragonfly_libvips
|
29
|
+
```
|
30
|
+
|
31
|
+
## Dependencies
|
32
|
+
|
33
|
+
The [vips](http://www.vips.ecs.soton.ac.uk/index.php?title=Supported) library and its [dependencies](https://github.com/jcupitt/libvips#dependencies).
|
34
|
+
|
35
|
+
## Usage
|
36
|
+
|
37
|
+
Configure your app the usual way:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
Dragonfly.app.configure do
|
41
|
+
plugin :libvips
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
### Processors
|
46
|
+
|
47
|
+
#### Thumb
|
48
|
+
|
49
|
+
Create a thumbnail by resizing/cropping
|
50
|
+
|
51
|
+
```ruby
|
52
|
+
image.thumb('40x30')
|
53
|
+
```
|
54
|
+
|
55
|
+
Below are some examples of geometry strings for `thumb`:
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
'400x300' # resize, maintain aspect ratio
|
59
|
+
'400x' # resize width, maintain aspect ratio
|
60
|
+
'x300' # resize height, maintain aspect ratio
|
61
|
+
'400x300<' # resize only if the image is smaller than this
|
62
|
+
'400x300>' # resize only if the image is larger than this
|
63
|
+
```
|
64
|
+
|
65
|
+
#### Encode
|
66
|
+
|
67
|
+
Change the encoding with
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
image.encode('jpg')
|
71
|
+
```
|
72
|
+
|
73
|
+
optionally pass output arguments (specific to format)
|
74
|
+
|
75
|
+
```ruby
|
76
|
+
image.encode('jpg', 'Q=50')
|
77
|
+
```
|
78
|
+
|
79
|
+
#### Rotate
|
80
|
+
|
81
|
+
Rotate a number of degrees with
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
image.rotate(90)
|
85
|
+
```
|
86
|
+
|
87
|
+
#### Vips
|
88
|
+
|
89
|
+
Perform an arbitrary `vips` command
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
image.vips('resize', '0.5', { 'input_args' => 'page=2', 'output_args' => 'Q=50', 'format' => 'jpg' })
|
93
|
+
```
|
94
|
+
|
95
|
+
corresponds to the command-line
|
96
|
+
|
97
|
+
```
|
98
|
+
vips resize <original_path>[page=2] <new_path>[Q=50] 0.5
|
99
|
+
```
|
100
|
+
|
101
|
+
#### Vipsthumbnail
|
102
|
+
|
103
|
+
Perform an arbitrary `vipsthumbnail` command
|
104
|
+
|
105
|
+
```ruby
|
106
|
+
image.vips('--size=100x100', { 'input_args' => 'page=2', 'output_args' => 'Q=50', 'format' => 'jpg' })
|
107
|
+
```
|
108
|
+
|
109
|
+
corresponds to the command-line
|
110
|
+
|
111
|
+
```
|
112
|
+
vipsthumbnail <original_path>[page=2] --size=100x100 -o <new-path>[Q=50]
|
113
|
+
```
|
114
|
+
|
115
|
+
### Analysers
|
116
|
+
|
117
|
+
The following methods are provided
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
image.width # => 280
|
121
|
+
image.height # => 355
|
122
|
+
image.aspect_ratio # => 0.788732394366197
|
123
|
+
image.portrait? # => true
|
124
|
+
image.landscape? # => false
|
125
|
+
image.format # => 'png'
|
126
|
+
image.image? # => true
|
127
|
+
```
|
128
|
+
|
129
|
+
### Configuration
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
Dragonfly.app.configure do
|
133
|
+
plugin :libvips,
|
134
|
+
vips_command: "/opt/local/bin/vips" # defaults to "vips"
|
135
|
+
vipsheader_command: "/opt/local/bin/vipsheader" # defaults to "vipsheader"
|
136
|
+
vipsthumbnail_command: "/opt/local/bin/vipsthumbnail" # defaults to "vipsthumbnail"
|
137
|
+
end
|
138
|
+
```
|
139
|
+
|
140
|
+
## Acknowledgements
|
141
|
+
|
142
|
+
This plugin, its structure, sample files, tests as well as this README are based on the original Dragonfly's [ImageMagick plugin](http://markevans.github.io/dragonfly/imagemagick) by Mark Evans.
|
143
|
+
|
144
|
+
## Development
|
145
|
+
|
146
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
147
|
+
|
148
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
149
|
+
|
150
|
+
## Contributing
|
151
|
+
|
152
|
+
Bug reports and pull requests are welcome on GitHub at <https://github.com/tomasc/dragonfly_libvips>.
|
153
|
+
|
154
|
+
## License
|
155
|
+
|
156
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dragonfly_libvips"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'dragonfly_libvips/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'dragonfly_libvips'
|
8
|
+
spec.version = DragonflyLibvips::VERSION
|
9
|
+
spec.authors = ['Tomas Celizna']
|
10
|
+
spec.email = ['tomas.celizna@gmail.com']
|
11
|
+
|
12
|
+
spec.summary = 'Dragonfly analysers and processors for libvips image processing library.'
|
13
|
+
spec.homepage = 'https://github.com/tomasc/dragonfly_libvips'
|
14
|
+
spec.license = 'MIT'
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = 'exe'
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ['lib']
|
20
|
+
|
21
|
+
spec.add_dependency 'dragonfly', '~> 1.0'
|
22
|
+
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.12'
|
24
|
+
spec.add_development_dependency 'guard'
|
25
|
+
spec.add_development_dependency 'guard-minitest'
|
26
|
+
spec.add_development_dependency 'minitest', '~> 5.0'
|
27
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
28
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module DragonflyLibvips
|
2
|
+
module Analysers
|
3
|
+
class ImageProperties
|
4
|
+
def call(content)
|
5
|
+
vipsheader_command = content.env[:vipsheader_command] || 'vipsheader'
|
6
|
+
details = content.shell_eval do |path|
|
7
|
+
"#{vipsheader_command} #{path}"
|
8
|
+
end
|
9
|
+
|
10
|
+
_filename, dimensions, _bands, _interpretation, vips_loader = details.split(/\s*[:,]\s*/)
|
11
|
+
width, height = dimensions.split(/\s+/).first.split('x')
|
12
|
+
format = vips_loader.gsub(/\s*load\s*/, '').downcase
|
13
|
+
|
14
|
+
{
|
15
|
+
'format' => format.downcase,
|
16
|
+
'width' => width.to_i,
|
17
|
+
'height' => height.to_i
|
18
|
+
}
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'dragonfly/shell'
|
2
|
+
require 'dragonfly_libvips/analysers/image_properties'
|
3
|
+
require 'dragonfly_libvips/processors/encode'
|
4
|
+
require 'dragonfly_libvips/processors/thumb'
|
5
|
+
require 'dragonfly_libvips/processors/vips'
|
6
|
+
require 'dragonfly_libvips/processors/vipsthumbnail'
|
7
|
+
|
8
|
+
module DragonflyLibvips
|
9
|
+
class Plugin
|
10
|
+
def call(app, opts = {})
|
11
|
+
# ENV
|
12
|
+
app.env[:vips_command] = opts[:vips_command] || 'vips'
|
13
|
+
app.env[:vipsheader_command] = opts[:vipsheader_command] || 'vipsheader'
|
14
|
+
app.env[:vipsthumbnail_command] = opts[:vipsthumbnail_command] || 'vipsthumbnail'
|
15
|
+
|
16
|
+
# Analysers
|
17
|
+
app.add_analyser :image_properties, DragonflyLibvips::Analysers::ImageProperties.new
|
18
|
+
|
19
|
+
app.add_analyser :width do |content|
|
20
|
+
content.analyse(:image_properties)['width']
|
21
|
+
end
|
22
|
+
|
23
|
+
app.add_analyser :height do |content|
|
24
|
+
content.analyse(:image_properties)['height']
|
25
|
+
end
|
26
|
+
|
27
|
+
app.add_analyser :format do |content|
|
28
|
+
content.analyse(:image_properties)['format']
|
29
|
+
end
|
30
|
+
|
31
|
+
app.add_analyser :aspect_ratio do |content|
|
32
|
+
attrs = content.analyse(:image_properties)
|
33
|
+
attrs['width'].to_f / attrs['height']
|
34
|
+
end
|
35
|
+
|
36
|
+
app.add_analyser :portrait do |content|
|
37
|
+
attrs = content.analyse(:image_properties)
|
38
|
+
attrs['width'] <= attrs['height']
|
39
|
+
end
|
40
|
+
|
41
|
+
app.add_analyser :landscape do |content|
|
42
|
+
!content.analyse(:portrait)
|
43
|
+
end
|
44
|
+
|
45
|
+
app.add_analyser :image do |content|
|
46
|
+
begin
|
47
|
+
content.analyse(:image_properties).key?('format')
|
48
|
+
rescue Dragonfly::Shell::CommandFailed
|
49
|
+
false
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Aliases
|
54
|
+
app.define(:portrait?) { portrait }
|
55
|
+
app.define(:landscape?) { landscape }
|
56
|
+
app.define(:image?) { image }
|
57
|
+
|
58
|
+
# Processors
|
59
|
+
app.add_processor :encode, Processors::Encode.new
|
60
|
+
app.add_processor :thumb, Processors::Thumb.new
|
61
|
+
app.add_processor :vips, Processors::Vips.new
|
62
|
+
app.add_processor :vipsthumbnail, Processors::Vipsthumbnail.new
|
63
|
+
app.add_processor :rotate do |content, amount|
|
64
|
+
content.process!(:vips, 'rot', "d#{amount}")
|
65
|
+
end
|
66
|
+
|
67
|
+
# Extra methods
|
68
|
+
app.define :vipsheader do |*args|
|
69
|
+
cli_args = args.first # because ruby 1.8.7 can't deal with default args in blocks
|
70
|
+
shell_eval do |path|
|
71
|
+
"#{app.env[:vipsheader_command]} #{cli_args} #{path}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
Dragonfly::App.register_plugin(:libvips) { DragonflyLibvips::Plugin.new }
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module DragonflyLibvips
|
2
|
+
module Processors
|
3
|
+
class Encode
|
4
|
+
def call(content, format, output_args = '')
|
5
|
+
opts = { 'format' => format, 'output_args' => output_args }
|
6
|
+
content.process!(:vips, 'copy', '', opts)
|
7
|
+
end
|
8
|
+
|
9
|
+
def update_url(attrs, format, _args = '')
|
10
|
+
attrs.ext = format.to_s
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module DragonflyLibvips
|
2
|
+
module Processors
|
3
|
+
class Thumb
|
4
|
+
OPERATORS = '><'.freeze
|
5
|
+
RESIZE_GEOMETRY = /\A\d*x\d*[#{OPERATORS}]?\z/ # e.g. '300x200>'
|
6
|
+
|
7
|
+
def update_url(url_attributes, _geometry, opts = {})
|
8
|
+
format = opts['format']
|
9
|
+
url_attributes.ext = format if format
|
10
|
+
end
|
11
|
+
|
12
|
+
def call(content, geometry, opts = {})
|
13
|
+
image_properties = content.analyse(:image_properties)
|
14
|
+
content.process!(:vipsthumbnail, args_for_geometry(geometry, image_properties), opts)
|
15
|
+
end
|
16
|
+
|
17
|
+
def args_for_geometry(geometry, image_properties)
|
18
|
+
case geometry
|
19
|
+
when RESIZE_GEOMETRY then resize_args(geometry, image_properties)
|
20
|
+
else raise ArgumentError, "Didn't recognise the geometry string #{geometry}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def resize_args(geometry, image_properties)
|
27
|
+
w = image_properties['width']
|
28
|
+
h = image_properties['height']
|
29
|
+
ratio = w.to_f / h.to_f
|
30
|
+
is_landscape = ratio > 1.0
|
31
|
+
|
32
|
+
width, height = geometry.scan(/\A(\d*)x(\d*)/).flatten.map(&:to_i)
|
33
|
+
|
34
|
+
case geometry
|
35
|
+
when /\Ax\d+[#{OPERATORS}]?/
|
36
|
+
width = is_landscape ? (ratio * height).round : height
|
37
|
+
when /\A\d+x[#{OPERATORS}]?\z/
|
38
|
+
height = is_landscape ? width : (width / ratio).round
|
39
|
+
end
|
40
|
+
|
41
|
+
case geometry
|
42
|
+
when />\z/
|
43
|
+
width, height = w, h if width >= w || height >= h
|
44
|
+
when /<\z/
|
45
|
+
width, height = w, h if width <= w && height <= h
|
46
|
+
end
|
47
|
+
|
48
|
+
dimensions = "#{width}x#{height}"
|
49
|
+
"-s #{dimensions}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module DragonflyLibvips
|
2
|
+
module Processors
|
3
|
+
class Vips
|
4
|
+
def call(content, commands, args = '', opts = {})
|
5
|
+
vips_command = content.env[:vips_command] || 'vips'
|
6
|
+
format = opts['format']
|
7
|
+
|
8
|
+
if input_args = opts['input_args']
|
9
|
+
input_args = "[#{input_args}]"
|
10
|
+
end
|
11
|
+
|
12
|
+
if output_args = opts['output_args']
|
13
|
+
output_args = "[#{output_args}]"
|
14
|
+
end
|
15
|
+
|
16
|
+
content.shell_update ext: format do |old_path, new_path|
|
17
|
+
"#{vips_command} #{commands} #{old_path}#{input_args} #{new_path}#{output_args} #{args}"
|
18
|
+
end
|
19
|
+
|
20
|
+
if format
|
21
|
+
content.meta['format'] = format.to_s
|
22
|
+
content.ext = format
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def update_url(attrs, _commands, _args = '', opts = {})
|
27
|
+
format = opts['format']
|
28
|
+
attrs.ext = format if format
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module DragonflyLibvips
|
2
|
+
module Processors
|
3
|
+
class Vipsthumbnail
|
4
|
+
def call(content, args = '', opts = {})
|
5
|
+
vipsthumbnail_command = content.env[:vipsthumbnail_command] || 'vipsthumbnail'
|
6
|
+
format = opts['format']
|
7
|
+
|
8
|
+
content.shell_update ext: format do |old_path, new_path|
|
9
|
+
"#{vipsthumbnail_command} #{old_path} -o #{new_path} #{args}"
|
10
|
+
end
|
11
|
+
|
12
|
+
if format
|
13
|
+
content.meta['format'] = format.to_s
|
14
|
+
content.ext = format
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def update_url(attrs, _args = '', opts = {})
|
19
|
+
format = opts['format']
|
20
|
+
attrs.ext = format if format
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/samples/beach.png
ADDED
Binary file
|
Binary file
|
data/samples/memo.pdf
ADDED
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,151 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: dragonfly_libvips
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Tomas Celizna
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-08-20 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: dragonfly
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.12'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.12'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: guard
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: guard-minitest
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: minitest
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '5.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '5.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '10.0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '10.0'
|
97
|
+
description:
|
98
|
+
email:
|
99
|
+
- tomas.celizna@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- ".gitignore"
|
105
|
+
- ".travis.yml"
|
106
|
+
- CHANGELOG.md
|
107
|
+
- Gemfile
|
108
|
+
- Guardfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- bin/console
|
113
|
+
- bin/setup
|
114
|
+
- dragonfly_libvips.gemspec
|
115
|
+
- lib/dragonfly_libvips.rb
|
116
|
+
- lib/dragonfly_libvips/analysers/image_properties.rb
|
117
|
+
- lib/dragonfly_libvips/plugin.rb
|
118
|
+
- lib/dragonfly_libvips/processors/encode.rb
|
119
|
+
- lib/dragonfly_libvips/processors/thumb.rb
|
120
|
+
- lib/dragonfly_libvips/processors/vips.rb
|
121
|
+
- lib/dragonfly_libvips/processors/vipsthumbnail.rb
|
122
|
+
- lib/dragonfly_libvips/version.rb
|
123
|
+
- samples/beach.png
|
124
|
+
- samples/landscape_beach.png
|
125
|
+
- samples/memo.pdf
|
126
|
+
- samples/white pixel.png
|
127
|
+
homepage: https://github.com/tomasc/dragonfly_libvips
|
128
|
+
licenses:
|
129
|
+
- MIT
|
130
|
+
metadata: {}
|
131
|
+
post_install_message:
|
132
|
+
rdoc_options: []
|
133
|
+
require_paths:
|
134
|
+
- lib
|
135
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
136
|
+
requirements:
|
137
|
+
- - ">="
|
138
|
+
- !ruby/object:Gem::Version
|
139
|
+
version: '0'
|
140
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
145
|
+
requirements: []
|
146
|
+
rubyforge_project:
|
147
|
+
rubygems_version: 2.4.5.1
|
148
|
+
signing_key:
|
149
|
+
specification_version: 4
|
150
|
+
summary: Dragonfly analysers and processors for libvips image processing library.
|
151
|
+
test_files: []
|