image_processing 1.0.0 → 1.1.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 +8 -0
- data/README.md +1 -1
- data/lib/image_processing/chainable.rb +4 -0
- data/lib/image_processing/mini_magick.rb +13 -10
- data/lib/image_processing/processor.rb +10 -0
- data/lib/image_processing/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 908334dfbdaa9424701386bb8c1722d23679f726
|
4
|
+
data.tar.gz: abbc3ca67468cedb3729aae261e04e49f1d19cf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 151d52c9bba7feb70a516cda8e59b865e4684993646703219d0806aa0a92b6511cbd15d6af0b0f6d83b948a85926a35a465ccc4bc96531a68e499c4556743ed7
|
7
|
+
data.tar.gz: bcfb395d26a68bfe7cb21994a319fc982bbd8702a83123d7ac825064c582e46a5bedf3c33263b7f0f6b28e6420786ec1e54b029abf54ed90c487ad52539318ff
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.1.0 (2018-04-05)
|
2
|
+
|
3
|
+
* [minimagick] Disallow splitting multi-layer images into multiple single-layer
|
4
|
+
images by default to avoid unexpected behaviour, but can be re-enabled with
|
5
|
+
the `:allow_splitting` saver option (@janko-m)
|
6
|
+
|
7
|
+
* [core] Add `#apply` for applying a list of operations (@janko-m)
|
8
|
+
|
1
9
|
## 1.0.0 (2018-04-04)
|
2
10
|
|
3
11
|
* Depend on `mini_magick` and `ruby-vips` gems (@janko-m, @mokolabs)
|
data/README.md
CHANGED
@@ -5,7 +5,7 @@ when handling image uploads.
|
|
5
5
|
|
6
6
|
This gem can process images with either [ImageMagick] or [libvips] libraries.
|
7
7
|
ImageMagick is a good default choice, especially if you are migrating from
|
8
|
-
another gem or library that uses ImageMagick.
|
8
|
+
another gem or library that uses ImageMagick. Libvips is a newer library that
|
9
9
|
can process images [very rapidly][libvips performance] (up to 10x faster than
|
10
10
|
ImageMagick).
|
11
11
|
|
@@ -70,12 +70,13 @@ module ImageProcessing
|
|
70
70
|
magick
|
71
71
|
end
|
72
72
|
|
73
|
-
def save_image(magick, destination_path, **options)
|
73
|
+
def save_image(magick, destination_path, allow_splitting: false, **options)
|
74
74
|
apply_options(magick, options)
|
75
75
|
|
76
76
|
magick << destination_path
|
77
|
-
|
78
77
|
magick.call
|
78
|
+
|
79
|
+
disallow_split_layers!(destination_path) unless allow_splitting
|
79
80
|
end
|
80
81
|
|
81
82
|
private
|
@@ -94,14 +95,7 @@ module ImageProcessing
|
|
94
95
|
end
|
95
96
|
|
96
97
|
def apply_options(magick, define: {}, **options)
|
97
|
-
|
98
|
-
case value
|
99
|
-
when true, nil then magick.send(option)
|
100
|
-
when false then magick.send(option).+
|
101
|
-
else magick.send(option, *value)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
98
|
+
apply(magick, options)
|
105
99
|
apply_define(magick, define)
|
106
100
|
end
|
107
101
|
|
@@ -121,6 +115,15 @@ module ImageProcessing
|
|
121
115
|
magick.args.replace args + magick.args
|
122
116
|
magick
|
123
117
|
end
|
118
|
+
|
119
|
+
def disallow_split_layers!(destination_path)
|
120
|
+
layers = Dir[destination_path.sub(/\.\w+$/, '-*\0')]
|
121
|
+
|
122
|
+
if layers.any?
|
123
|
+
layers.each { |path| File.delete(path) }
|
124
|
+
raise Error, "Multi-layer image is being converted into a single-layer format. You should either process individual layers or set :allow_splitting to true. See https://github.com/janko-m/image_processing/wiki/Splitting-a-PDF-into-multiple-images for how to process each layer individually."
|
125
|
+
end
|
126
|
+
end
|
124
127
|
end
|
125
128
|
|
126
129
|
extend Chainable
|
@@ -4,6 +4,16 @@ module ImageProcessing
|
|
4
4
|
@pipeline = pipeline
|
5
5
|
end
|
6
6
|
|
7
|
+
def apply(image, operations)
|
8
|
+
operations.inject(image) do |result, (name, args)|
|
9
|
+
if args == true || args.nil?
|
10
|
+
apply_operation(name, result)
|
11
|
+
else
|
12
|
+
apply_operation(name, result, *args)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
7
17
|
def apply_operation(name, image, *args)
|
8
18
|
if respond_to?(name)
|
9
19
|
public_send(name, image, *args)
|
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.1.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: 2018-04-
|
11
|
+
date: 2018-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: mini_magick
|