image_processing 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of image_processing might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/image_processing.gemspec +1 -1
- data/lib/image_processing/mini_magick.rb +2 -2
- data/lib/image_processing/processor.rb +12 -1
- data/lib/image_processing/version.rb +1 -1
- data/lib/image_processing/vips.rb +19 -12
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ffa40592c60c9cdd802c66603dd364a5eabc2c3b0b784df8e6646bab22976916
|
4
|
+
data.tar.gz: fdb4f77ccd655719bdd9650816ae20fd80db7f192d267db8b3081a9e4beae476
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b1be056214e0da7b38cc229bcd4e48d7962514777881de9c93ddd68ccb5de8bd29bfada6afbf03a78007aee860d1bb706dc2f35f3e192c0861110df8e71c3a31
|
7
|
+
data.tar.gz: fa16784ff04521cb24608869f159185586e61f9ecaedc977ac89e550a1209e921f91590ea71b27fbeb4ab3a49f1ee545fd44d8291d83687d4e309d31dada3a28
|
data/CHANGELOG.md
CHANGED
data/image_processing.gemspec
CHANGED
@@ -4,7 +4,7 @@ Gem::Specification.new do |spec|
|
|
4
4
|
spec.name = "image_processing"
|
5
5
|
spec.version = ImageProcessing::VERSION
|
6
6
|
|
7
|
-
spec.required_ruby_version = ">= 2.
|
7
|
+
spec.required_ruby_version = ">= 2.4"
|
8
8
|
|
9
9
|
spec.summary = "Set of higher-level helper methods for image processing."
|
10
10
|
spec.description = "Set of higher-level helper methods for image processing."
|
@@ -25,7 +25,7 @@ module ImageProcessing
|
|
25
25
|
# Initializes the image on disk into a MiniMagick::Tool object. Accepts
|
26
26
|
# additional options related to loading the image (e.g. geometry).
|
27
27
|
# Additionally auto-orients the image to be upright.
|
28
|
-
def self.load_image(path_or_magick,
|
28
|
+
def self.load_image(path_or_magick, page: nil, geometry: nil, auto_orient: true, **options)
|
29
29
|
if path_or_magick.is_a?(::MiniMagick::Tool)
|
30
30
|
magick = path_or_magick
|
31
31
|
else
|
@@ -195,7 +195,7 @@ module ImageProcessing
|
|
195
195
|
|
196
196
|
if layers.any?
|
197
197
|
layers.each { |path| File.delete(path) }
|
198
|
-
raise Error, "
|
198
|
+
raise Error, "Source format is multi-layer, but destination format is single-layer. If you care only about the first layer, add `.loader(page: 0)` to your pipeline. If you want to process each layer, see https://github.com/janko/image_processing/wiki/Splitting-a-PDF-into-multiple-images or use `.saver(allow_splitting: true)`."
|
199
199
|
end
|
200
200
|
end
|
201
201
|
|
@@ -6,7 +6,14 @@ module ImageProcessing
|
|
6
6
|
fail Error, "invalid source: #{source.inspect}"
|
7
7
|
end
|
8
8
|
|
9
|
-
|
9
|
+
if operations.dig(0, 0).to_s.start_with?("resize_") &&
|
10
|
+
loader.empty? &&
|
11
|
+
supports_resize_on_load?
|
12
|
+
|
13
|
+
accumulator = source
|
14
|
+
else
|
15
|
+
accumulator = load_image(source, **loader)
|
16
|
+
end
|
10
17
|
|
11
18
|
operations.each do |operation|
|
12
19
|
accumulator = apply_operation(accumulator, operation)
|
@@ -40,6 +47,10 @@ module ImageProcessing
|
|
40
47
|
end
|
41
48
|
end
|
42
49
|
|
50
|
+
def self.supports_resize_on_load?
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
43
54
|
def initialize(accumulator = nil)
|
44
55
|
@accumulator = accumulator
|
45
56
|
end
|
@@ -27,34 +27,41 @@ module ImageProcessing
|
|
27
27
|
# Loads the image on disk into a Vips::Image object. Accepts additional
|
28
28
|
# loader-specific options (e.g. interlacing). Afterwards auto-rotates the
|
29
29
|
# image to be upright.
|
30
|
-
def self.load_image(path_or_image,
|
30
|
+
def self.load_image(path_or_image, loader: nil, autorot: true, **options)
|
31
31
|
if path_or_image.is_a?(::Vips::Image)
|
32
32
|
image = path_or_image
|
33
33
|
else
|
34
34
|
path = path_or_image
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
image = ::Vips::Image.new_from_file(path, **options)
|
36
|
+
if loader
|
37
|
+
image = ::Vips::Image.public_send(:"#{loader}load", path, **options)
|
38
|
+
else
|
39
|
+
options = Utils.select_valid_loader_options(path, options)
|
40
|
+
image = ::Vips::Image.new_from_file(path, **options)
|
41
|
+
end
|
44
42
|
end
|
45
43
|
|
46
44
|
image = image.autorot if autorot && !options.key?(:autorotate)
|
47
45
|
image
|
48
46
|
end
|
49
47
|
|
48
|
+
# See #thumbnail.
|
49
|
+
def self.supports_resize_on_load?
|
50
|
+
true
|
51
|
+
end
|
52
|
+
|
50
53
|
# Writes the Vips::Image object to disk. This starts the processing
|
51
54
|
# pipeline defined in the Vips::Image object. Accepts additional
|
52
55
|
# saver-specific options (e.g. quality).
|
53
|
-
def self.save_image(image,
|
56
|
+
def self.save_image(image, path, saver: nil, quality: nil, **options)
|
54
57
|
options = options.merge(Q: quality) if quality
|
55
|
-
options = Utils.select_valid_saver_options(destination_path, options)
|
56
58
|
|
57
|
-
|
59
|
+
if saver
|
60
|
+
image.public_send(:"#{saver}save", path, **options)
|
61
|
+
else
|
62
|
+
options = Utils.select_valid_saver_options(path, options)
|
63
|
+
image.write_to_file(path, **options)
|
64
|
+
end
|
58
65
|
end
|
59
66
|
|
60
67
|
# Resizes the image to not be larger than the specified dimensions.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: image_processing
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Janko Marohnić
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-04-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|
@@ -151,14 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
151
151
|
requirements:
|
152
152
|
- - ">="
|
153
153
|
- !ruby/object:Gem::Version
|
154
|
-
version: '2.
|
154
|
+
version: '2.4'
|
155
155
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - ">="
|
158
158
|
- !ruby/object:Gem::Version
|
159
159
|
version: '0'
|
160
160
|
requirements: []
|
161
|
-
rubygems_version: 3.0.
|
161
|
+
rubygems_version: 3.0.3
|
162
162
|
signing_key:
|
163
163
|
specification_version: 4
|
164
164
|
summary: Set of higher-level helper methods for image processing.
|