mini_magick 4.7.0 → 4.8.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/lib/mini_magick/image.rb +16 -14
- data/lib/mini_magick/tool/mogrify_restricted.rb +15 -0
- data/lib/mini_magick/tool.rb +2 -1
- data/lib/mini_magick/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 49a53e90d9387b9fa7dbb83e10e08fcc7650e2e8
|
|
4
|
+
data.tar.gz: af2fecfe830084869b34bd41b6b2077b5ec4218a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa011122b74d076892ae48198f56b71ab809f20bdca8d56c1a0754ccd7711c03093bcd6721b6b15aedd4599ede040ccb3d23d4947dbf4748f7531b5e68f0e5bb
|
|
7
|
+
data.tar.gz: 2507b667f71982f46c181a4b0ae8c55f94a2d01338f035a98e0df38ff18639b39a957bbd754c6b481e61c0a95f446e16e157e4b9562c1551f2696651c7ef22f0
|
data/lib/mini_magick/image.rb
CHANGED
|
@@ -76,9 +76,12 @@ module MiniMagick
|
|
|
76
76
|
# @param path_or_url [String] Either a local file path or a URL that
|
|
77
77
|
# open-uri can read
|
|
78
78
|
# @param ext [String] Specify the extension you want to read it as
|
|
79
|
+
# @param options [Hash] Specify options for the open method
|
|
79
80
|
# @return [MiniMagick::Image] The loaded image
|
|
80
81
|
#
|
|
81
|
-
def self.open(path_or_url, ext = nil)
|
|
82
|
+
def self.open(path_or_url, ext = nil, options = {})
|
|
83
|
+
options, ext = ext, nil if ext.is_a?(Hash)
|
|
84
|
+
|
|
82
85
|
ext ||=
|
|
83
86
|
if File.exist?(path_or_url)
|
|
84
87
|
File.extname(path_or_url)
|
|
@@ -86,7 +89,9 @@ module MiniMagick
|
|
|
86
89
|
File.extname(URI(path_or_url).path)
|
|
87
90
|
end
|
|
88
91
|
|
|
89
|
-
|
|
92
|
+
ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon
|
|
93
|
+
|
|
94
|
+
Kernel.open(path_or_url, "rb", options) do |file|
|
|
90
95
|
read(file, ext)
|
|
91
96
|
end
|
|
92
97
|
end
|
|
@@ -341,11 +346,14 @@ module MiniMagick
|
|
|
341
346
|
#
|
|
342
347
|
# @return [Array] Matrix of each color of each pixel
|
|
343
348
|
def get_pixels
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
+
convert = MiniMagick::Tool::Convert.new
|
|
350
|
+
convert << path
|
|
351
|
+
convert.depth(8)
|
|
352
|
+
convert << "RGB:-"
|
|
353
|
+
|
|
354
|
+
# Do not use `convert.call` here. We need the whole binary (unstripped) output here.
|
|
355
|
+
shell = MiniMagick::Shell.new
|
|
356
|
+
output, * = shell.run(convert.command)
|
|
349
357
|
|
|
350
358
|
pixels_array = output.unpack("C*")
|
|
351
359
|
pixels = pixels_array.each_slice(3).each_slice(width).to_a
|
|
@@ -553,13 +561,7 @@ module MiniMagick
|
|
|
553
561
|
end
|
|
554
562
|
|
|
555
563
|
def mogrify(page = nil)
|
|
556
|
-
MiniMagick::Tool::
|
|
557
|
-
builder.instance_eval do
|
|
558
|
-
def format(*args)
|
|
559
|
-
fail NoMethodError,
|
|
560
|
-
"you must call #format on a MiniMagick::Image directly"
|
|
561
|
-
end
|
|
562
|
-
end
|
|
564
|
+
MiniMagick::Tool::MogrifyRestricted.new do |builder|
|
|
563
565
|
yield builder if block_given?
|
|
564
566
|
builder << (page ? "#{path}[#{page}]" : path)
|
|
565
567
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
require "mini_magick/tool/mogrify"
|
|
2
|
+
|
|
3
|
+
module MiniMagick
|
|
4
|
+
class Tool
|
|
5
|
+
##
|
|
6
|
+
# @see http://www.imagemagick.org/script/mogrify.php
|
|
7
|
+
#
|
|
8
|
+
class MogrifyRestricted < Mogrify
|
|
9
|
+
def format(*args)
|
|
10
|
+
fail NoMethodError,
|
|
11
|
+
"you must call #format on a MiniMagick::Image directly"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
data/lib/mini_magick/tool.rb
CHANGED
|
@@ -92,7 +92,7 @@ module MiniMagick
|
|
|
92
92
|
stdout, stderr, status = shell.run(command, options)
|
|
93
93
|
yield stdout, stderr, status if block_given?
|
|
94
94
|
|
|
95
|
-
stdout.
|
|
95
|
+
stdout.chomp("\n")
|
|
96
96
|
end
|
|
97
97
|
|
|
98
98
|
##
|
|
@@ -286,5 +286,6 @@ require "mini_magick/tool/display"
|
|
|
286
286
|
require "mini_magick/tool/identify"
|
|
287
287
|
require "mini_magick/tool/import"
|
|
288
288
|
require "mini_magick/tool/mogrify"
|
|
289
|
+
require "mini_magick/tool/mogrify_restricted"
|
|
289
290
|
require "mini_magick/tool/montage"
|
|
290
291
|
require "mini_magick/tool/stream"
|
data/lib/mini_magick/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: mini_magick
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 4.
|
|
4
|
+
version: 4.8.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Corey Johnson
|
|
@@ -13,7 +13,7 @@ authors:
|
|
|
13
13
|
autorequire:
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
|
-
date: 2017-
|
|
16
|
+
date: 2017-07-06 00:00:00.000000000 Z
|
|
17
17
|
dependencies:
|
|
18
18
|
- !ruby/object:Gem::Dependency
|
|
19
19
|
name: rake
|
|
@@ -85,6 +85,20 @@ dependencies:
|
|
|
85
85
|
- - ">="
|
|
86
86
|
- !ruby/object:Gem::Version
|
|
87
87
|
version: '0'
|
|
88
|
+
- !ruby/object:Gem::Dependency
|
|
89
|
+
name: webmock
|
|
90
|
+
requirement: !ruby/object:Gem::Requirement
|
|
91
|
+
requirements:
|
|
92
|
+
- - ">="
|
|
93
|
+
- !ruby/object:Gem::Version
|
|
94
|
+
version: '0'
|
|
95
|
+
type: :development
|
|
96
|
+
prerelease: false
|
|
97
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
98
|
+
requirements:
|
|
99
|
+
- - ">="
|
|
100
|
+
- !ruby/object:Gem::Version
|
|
101
|
+
version: '0'
|
|
88
102
|
description: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
|
|
89
103
|
email:
|
|
90
104
|
- probablycorey@gmail.com
|
|
@@ -115,6 +129,7 @@ files:
|
|
|
115
129
|
- lib/mini_magick/tool/identify.rb
|
|
116
130
|
- lib/mini_magick/tool/import.rb
|
|
117
131
|
- lib/mini_magick/tool/mogrify.rb
|
|
132
|
+
- lib/mini_magick/tool/mogrify_restricted.rb
|
|
118
133
|
- lib/mini_magick/tool/montage.rb
|
|
119
134
|
- lib/mini_magick/tool/stream.rb
|
|
120
135
|
- lib/mini_magick/utilities.rb
|
|
@@ -140,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
140
155
|
requirements:
|
|
141
156
|
- You must have ImageMagick or GraphicsMagick installed
|
|
142
157
|
rubyforge_project:
|
|
143
|
-
rubygems_version: 2.
|
|
158
|
+
rubygems_version: 2.6.11
|
|
144
159
|
signing_key:
|
|
145
160
|
specification_version: 4
|
|
146
161
|
summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
|