dragonfly_libvips 2.3.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22507c180108f12d1b3ea9f5f3eca6073399fd203b1b51737806474488b1ce96
4
- data.tar.gz: c6e5f41766780ce99f72aff7ec8f8604720ba8c8eafdded36edc50e563eef22b
3
+ metadata.gz: 7eb4b31f2a9ef8e54c19288338ba8f737a701174bc00b4439a8d62e5433524d4
4
+ data.tar.gz: aca2f90bded5808371dc03d7dc93f4307a05428f44b7c48cdda2d0332871cd69
5
5
  SHA512:
6
- metadata.gz: 4dd8eb79e9a61b8f909469ba53235c3921d508298c7313e6ec1db1e061b840ef9b1d9280c04dc6a4c4eeba4ea2cebe26194a9f6bf5520399fbd4a219057ac65d
7
- data.tar.gz: cc7af38494afdd7fc9f20232a722cab5d99e6e196b018e7c17a4c10c5c575f02507f73f10bdcbce59df582f4b8da8d3143ee634c4de4e9227800ce9f8c26b3ef
6
+ metadata.gz: 0ef17138d0cf0a14ff4d497fa759628bd809d4855470c89a0634250ce576ffb2c71c20e7f4420d3ce036c45978262bcfc81a8211fe7e4d979b633018bbfbb005
7
+ data.tar.gz: 5d1c6afee3a94bd024d680e11bba822c59c0802b065b722fbc9829ea76ae30e39c9242991cfbccf55a9e06dce1090d3cc2ff89b7b9b4cf53a58a8228cb744070
@@ -0,0 +1 @@
1
+ 2.6.3
@@ -0,0 +1 @@
1
+ ruby 2.6.3
@@ -1,18 +1,19 @@
1
1
  # libvips build instructions taken from https://github.com/marcbachmann/dockerfile-libvips
2
2
 
3
3
  language: ruby
4
+ cache: bundler
4
5
  script: 'bundle exec rake'
5
6
  sudo: required
6
7
  dist: trusty
7
8
  rvm:
8
- - 2.2.5
9
+ - 2.6.3
9
10
 
10
11
  before_install:
11
- - gem install bundler -v 1.12.5
12
+ - gem update bundler
12
13
  - sudo apt-get update
13
- - sudo apt-get install -y gobject-introspection libgirepository1.0-dev libglib2.0-dev libpoppler-glib-dev
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
14
+ - sudo apt-get install -y gobject-introspection libgirepository1.0-dev libglib2.0-dev libpoppler-glib-dev libgif-dev
15
+ - curl -OL https://github.com/libvips/libvips/releases/download/v8.7.4/vips-8.7.4.tar.gz
16
+ - tar zxvf vips-8.7.4.tar.gz && cd vips-8.7.4 && ./configure $1 && sudo make && sudo make install
16
17
  - export GI_TYPELIB_PATH=/usr/local/lib/girepository-1.0/
17
18
  - sudo ldconfig
18
19
 
@@ -1,5 +1,27 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 2.4.2
4
+
5
+ * Add `webp` as supported format, and `aviz` and `heif` to formats without profile support (#14) by @asgerb
6
+
7
+ ## 2.4.1
8
+
9
+ * Fix misspelled UnsupportedOutputFormat (#13) by @asgerb
10
+ * Fix broken links in README (#12) by @NARKOZ
11
+
12
+ ## 2.4.0
13
+
14
+ * symbolize `input_options` and `output_options` to avoid argument errors coming from `ruby-vips`
15
+
16
+ ## 2.3.3
17
+
18
+ * locks `ruby-vips` to `< 2.0.14`
19
+ * adds support for `libvips` `8.8.0`
20
+
21
+ ## 2.3.2
22
+
23
+ * FIX: support for .gif
24
+
3
25
  ## 2.3.1
4
26
 
5
27
  * improved `SUPPORTED_FORMATS` matching that ignores case
data/README.md CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
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_libvips)
4
4
 
5
- Dragonfly analysers and processors for [libvips](https://github.com/jcupitt/libvips) image processing library
5
+ Dragonfly analysers and processors for [libvips](https://github.com/libvips/libvips) image processing library
6
6
 
7
7
  From the libvips README:
8
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+.
9
+ > libvips is a 2D image processing library. Compared to similar libraries, [libvips runs quickly and uses little memory](https://github.com/libvips/libvips/wiki/Speed-and-memory-use). libvips is licensed under the LGPL 2.1+.
10
10
 
11
11
  ## Installation
12
12
 
@@ -34,7 +34,7 @@ If you run into trouble installing `libvips` with Ruby introspection on Linux, f
34
34
 
35
35
  ## Dependencies
36
36
 
37
- The [vips](http://www.vips.ecs.soton.ac.uk/index.php?title=Supported) library and its [dependencies](https://github.com/jcupitt/libvips#dependencies).
37
+ The [vips](http://www.vips.ecs.soton.ac.uk/index.php?title=Supported) library and its [dependencies](https://github.com/libvips/libvips#dependencies).
38
38
 
39
39
  ## Usage
40
40
 
@@ -19,9 +19,10 @@ 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.6'
22
+ spec.add_dependency 'ruby-vips', '~> 2.0', '>= 2.0.16'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.12'
24
+ spec.add_development_dependency 'bundler'#, '~> 2.0'
25
+ spec.add_development_dependency 'rb-readline'
25
26
  spec.add_development_dependency 'guard'
26
27
  spec.add_development_dependency 'guard-minitest'
27
28
  spec.add_development_dependency 'minitest', '~> 5.0'
@@ -6,7 +6,7 @@ require 'vips'
6
6
 
7
7
  module DragonflyLibvips
8
8
  class UnsupportedFormat < RuntimeError; end
9
- class UnsupportedOutputormat < RuntimeError; end
9
+ class UnsupportedOutputFormat < RuntimeError; end
10
10
 
11
11
  CMYK_PROFILE_PATH = File.expand_path('../vendor/cmyk.icm', __dir__)
12
12
  EPROFILE_PATH = File.expand_path('../vendor/sRGB_v4_ICC_preference.icc', __dir__)
@@ -21,6 +21,9 @@ module DragonflyLibvips
21
21
  output.scan(/\.(\w{1,4})/).flatten.compact.sort.map(&:downcase).uniq
22
22
  end - %w[
23
23
  csv
24
+ fit
25
+ fits
26
+ fts
24
27
  mat
25
28
  pbm
26
29
  pfm
@@ -28,6 +31,17 @@ module DragonflyLibvips
28
31
  ppm
29
32
  v
30
33
  vips
31
- webp
32
34
  ]
35
+
36
+ FORMATS_WITHOUT_PROFILE_SUPPORT = %w[avif bmp dz gif hdr webp heic heif]
37
+
38
+ private
39
+
40
+ def self.stringify_keys(hash = {})
41
+ hash.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v }
42
+ end
43
+
44
+ def self.symbolize_keys(hash = {})
45
+ hash.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v }
46
+ end
33
47
  end
@@ -14,7 +14,7 @@ module DragonflyLibvips
14
14
  input_options['autorotate'] = true if content.mime_type == 'image/jpeg'
15
15
  input_options['dpi'] = DPI if content.mime_type == 'application/pdf'
16
16
 
17
- img = ::Vips::Image.new_from_file(content.path, input_options)
17
+ img = ::Vips::Image.new_from_file(content.path, DragonflyLibvips.symbolize_keys(input_options))
18
18
 
19
19
  width = img.width
20
20
  height = img.height
@@ -1,8 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'vips'
4
+
1
5
  module DragonflyLibvips
2
6
  module Processors
3
7
  class Encode
4
- FORMATS_WITHOUT_PROFILE_SUPPORT = %w[dz webp hdr]
5
-
6
8
  def call(content, format, options = {})
7
9
  raise UnsupportedFormat unless content.ext
8
10
  raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
@@ -19,31 +21,34 @@ module DragonflyLibvips
19
21
  return
20
22
  end
21
23
 
22
- options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
24
+ options = DragonflyLibvips.stringify_keys(options)
23
25
 
24
26
  input_options = options.fetch('input_options', {})
25
- output_options = options.fetch('output_options', {})
26
-
27
27
  input_options['access'] ||= 'sequential'
28
28
  if content.mime_type == 'image/jpeg'
29
- input_options['autorotate'] = true unless input_options.has_key?('autorotate')
29
+ input_options['autorotate'] = true unless input_options.key?('autorotate')
30
30
  end
31
31
 
32
- output_options['profile'] ||= EPROFILE_PATH
33
- output_options.delete('profile') if FORMATS_WITHOUT_PROFILE_SUPPORT.include?(format)
32
+ output_options = options.fetch('output_options', {})
33
+ if FORMATS_WITHOUT_PROFILE_SUPPORT.include?(format)
34
+ output_options.delete('profile')
35
+ else
36
+ output_options['profile'] ||= input_options.fetch('profile', EPROFILE_PATH)
37
+ end
38
+ output_options.delete('Q') unless format.to_s =~ /jpg|jpeg/i
39
+ output_options['format'] ||= format.to_s if format.to_s =~ /gif|bmp/i
34
40
 
35
- require 'vips'
36
- img = ::Vips::Image.new_from_file(content.path, input_options)
41
+ img = ::Vips::Image.new_from_file(content.path, DragonflyLibvips.symbolize_keys(input_options))
37
42
 
38
43
  content.update(
39
- img.write_to_buffer(".#{format}", output_options),
44
+ img.write_to_buffer(".#{format}", DragonflyLibvips.symbolize_keys(output_options)),
40
45
  'name' => "temp.#{format}",
41
46
  'format' => format
42
47
  )
43
48
  content.ext = format
44
49
  end
45
50
 
46
- def update_url(url_attributes, format, options = {})
51
+ def update_url(url_attributes, format, _options = {})
47
52
  url_attributes.ext = format.to_s
48
53
  end
49
54
  end
@@ -1,3 +1,5 @@
1
+ require 'vips'
2
+
1
3
  module DragonflyLibvips
2
4
  module Processors
3
5
  class ExtractArea
@@ -5,25 +7,30 @@ module DragonflyLibvips
5
7
  raise UnsupportedFormat unless content.ext
6
8
  raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
7
9
 
8
- options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
10
+ options = DragonflyLibvips.stringify_keys(options)
9
11
  format = options.fetch('format', content.ext)
10
12
 
11
13
  input_options = options.fetch('input_options', {})
12
- output_options = options.fetch('output_options', {})
13
14
 
14
15
  # input_options['access'] ||= 'sequential'
15
16
  if content.mime_type == 'image/jpeg'
16
17
  input_options['autorotate'] = true unless input_options.has_key?('autorotate')
17
18
  end
18
- output_options['profile'] ||= EPROFILE_PATH
19
19
 
20
- require 'vips'
21
- img = ::Vips::Image.new_from_file(content.path, input_options)
20
+ output_options = options.fetch('output_options', {})
21
+ if FORMATS_WITHOUT_PROFILE_SUPPORT.include?(format)
22
+ output_options.delete('profile')
23
+ else
24
+ output_options['profile'] ||= input_options.fetch('profile', EPROFILE_PATH)
25
+ end
26
+ output_options.delete('Q') unless format.to_s =~ /jpg|jpeg/i
27
+ output_options['format'] ||= format.to_s if format.to_s =~ /gif|bmp/i
22
28
 
29
+ img = ::Vips::Image.new_from_file(content.path, DragonflyLibvips.symbolize_keys(input_options))
23
30
  img = img.extract_area(x, y, width, height)
24
31
 
25
32
  content.update(
26
- img.write_to_buffer(".#{format}", output_options),
33
+ img.write_to_buffer(".#{format}", DragonflyLibvips.symbolize_keys(output_options)),
27
34
  'name' => "temp.#{format}",
28
35
  'format' => format
29
36
  )
@@ -1,3 +1,5 @@
1
+ require 'vips'
2
+
1
3
  module DragonflyLibvips
2
4
  module Processors
3
5
  class Rotate
@@ -5,25 +7,30 @@ module DragonflyLibvips
5
7
  raise UnsupportedFormat unless content.ext
6
8
  raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
7
9
 
8
- options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
10
+ options = DragonflyLibvips.stringify_keys(options)
9
11
  format = options.fetch('format', content.ext)
10
12
 
11
13
  input_options = options.fetch('input_options', {})
12
- output_options = options.fetch('output_options', {})
13
14
 
14
15
  # input_options['access'] ||= 'sequential'
15
16
  if content.mime_type == 'image/jpeg'
16
17
  input_options['autorotate'] = true unless input_options.has_key?('autorotate')
17
18
  end
18
- output_options['profile'] ||= EPROFILE_PATH
19
19
 
20
- require 'vips'
21
- img = ::Vips::Image.new_from_file(content.path, input_options)
20
+ output_options = options.fetch('output_options', {})
21
+ if FORMATS_WITHOUT_PROFILE_SUPPORT.include?(format)
22
+ output_options.delete('profile')
23
+ else
24
+ output_options['profile'] ||= input_options.fetch('profile', EPROFILE_PATH)
25
+ end
26
+ output_options.delete('Q') unless format.to_s =~ /jpg|jpeg/i
27
+ output_options['format'] ||= format.to_s if format.to_s =~ /gif|bmp/i
22
28
 
29
+ img = ::Vips::Image.new_from_file(content.path, DragonflyLibvips.symbolize_keys(input_options))
23
30
  img = img.rot("d#{rotate}")
24
31
 
25
32
  content.update(
26
- img.write_to_buffer(".#{format}", output_options),
33
+ img.write_to_buffer(".#{format}", DragonflyLibvips.symbolize_keys(output_options)),
27
34
  'name' => "temp.#{format}",
28
35
  'format' => format
29
36
  )
@@ -12,7 +12,7 @@ module DragonflyLibvips
12
12
  raise UnsupportedFormat unless content.ext
13
13
  raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext.downcase)
14
14
 
15
- options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
15
+ options = DragonflyLibvips.stringify_keys(options)
16
16
 
17
17
  filename = content.path
18
18
  format = options.fetch('format', content.ext).to_s
@@ -30,10 +30,16 @@ module DragonflyLibvips
30
30
  end
31
31
 
32
32
  output_options = options.fetch('output_options', {})
33
- output_options['profile'] = input_options.fetch('profile', EPROFILE_PATH)
33
+ if FORMATS_WITHOUT_PROFILE_SUPPORT.include?(format)
34
+ output_options.delete('profile')
35
+ else
36
+ output_options['profile'] ||= input_options.fetch('profile', EPROFILE_PATH)
37
+ end
38
+ output_options.delete('Q') unless format.to_s =~ /jpg|jpeg/i
39
+ output_options['format'] ||= format.to_s if format.to_s =~ /gif|bmp/i
34
40
 
35
41
  input_options = input_options.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v } # symbolize
36
- img = ::Vips::Image.new_from_file(filename, input_options)
42
+ img = ::Vips::Image.new_from_file(filename, DragonflyLibvips.symbolize_keys(input_options))
37
43
 
38
44
  dimensions = case geometry
39
45
  when RESIZE_GEOMETRY then Dimensions.call(geometry, img.width, img.height)
@@ -41,7 +47,11 @@ module DragonflyLibvips
41
47
  end
42
48
 
43
49
  thumbnail_options = options.fetch('thumbnail_options', {})
44
- thumbnail_options['auto_rotate'] = input_options.fetch('autorotate', true) if content.mime_type == 'image/jpeg'
50
+ if Vips.at_least_libvips?(8, 8)
51
+ thumbnail_options['no_rotate'] = input_options.fetch('no_rotate', false) if content.mime_type == 'image/jpeg'
52
+ else
53
+ thumbnail_options['auto_rotate'] = input_options.fetch('autorotate', true) if content.mime_type == 'image/jpeg'
54
+ end
45
55
  thumbnail_options['height'] = thumbnail_options.fetch('height', dimensions.height.ceil)
46
56
  thumbnail_options['import_profile'] = CMYK_PROFILE_PATH if img.get('interpretation') == :cmyk
47
57
  thumbnail_options['size'] ||= case geometry
@@ -53,10 +63,10 @@ module DragonflyLibvips
53
63
  filename += "[page=#{input_options[:page]}]" if content.mime_type == 'application/pdf'
54
64
 
55
65
  thumbnail_options = thumbnail_options.each_with_object({}) { |(k, v), memo| memo[k.to_sym] = v } # symbolize
56
- thumb = ::Vips::Image.thumbnail(filename, dimensions.width.ceil, thumbnail_options)
66
+ thumb = ::Vips::Image.thumbnail(filename, dimensions.width.ceil, DragonflyLibvips.symbolize_keys(thumbnail_options))
57
67
 
58
68
  content.update(
59
- thumb.write_to_buffer(".#{format}", output_options),
69
+ thumb.write_to_buffer(".#{format}", DragonflyLibvips.symbolize_keys(output_options)),
60
70
  'name' => "temp.#{format}",
61
71
  'format' => format
62
72
  )
@@ -1,3 +1,3 @@
1
1
  module DragonflyLibvips
2
- VERSION = '2.3.1'.freeze
2
+ VERSION = '2.4.2'.freeze
3
3
  end
Binary file
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.3.1
4
+ version: 2.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-09-18 00:00:00.000000000 Z
11
+ date: 2020-08-18 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.6
36
+ version: 2.0.16
37
37
  type: :runtime
38
38
  prerelease: false
39
39
  version_requirements: !ruby/object:Gem::Requirement
@@ -43,21 +43,35 @@ dependencies:
43
43
  version: '2.0'
44
44
  - - ">="
45
45
  - !ruby/object:Gem::Version
46
- version: 2.0.6
46
+ version: 2.0.16
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: bundler
49
49
  requirement: !ruby/object:Gem::Requirement
50
50
  requirements:
51
- - - "~>"
51
+ - - ">="
52
52
  - !ruby/object:Gem::Version
53
- version: '1.12'
53
+ version: '0'
54
54
  type: :development
55
55
  prerelease: false
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  requirements:
58
- - - "~>"
58
+ - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '1.12'
60
+ version: '0'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rb-readline
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ">="
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: '0'
61
75
  - !ruby/object:Gem::Dependency
62
76
  name: guard
63
77
  requirement: !ruby/object:Gem::Requirement
@@ -136,6 +150,8 @@ extensions: []
136
150
  extra_rdoc_files: []
137
151
  files:
138
152
  - ".gitignore"
153
+ - ".ruby-version"
154
+ - ".tool-versions"
139
155
  - ".travis.yml"
140
156
  - CHANGELOG.md
141
157
  - Gemfile
@@ -162,6 +178,7 @@ files:
162
178
  - samples/sample.png
163
179
  - samples/sample.svg
164
180
  - samples/sample.tif
181
+ - samples/sample_anim.gif
165
182
  - samples/sample_cmyk.jpg
166
183
  - samples/white pixel.png
167
184
  - vendor/cmyk.icm
@@ -185,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
185
202
  - !ruby/object:Gem::Version
186
203
  version: '0'
187
204
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.6
205
+ rubygems_version: 3.0.3
190
206
  signing_key:
191
207
  specification_version: 4
192
208
  summary: Dragonfly analysers and processors for libvips image processing library.