mini_magick 4.7.1 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a14b408f95ed836ca860d51f8eb0dbc62eb556bc
4
- data.tar.gz: c13c5e6456954d3e605aa4e72da0397ba679e18a
3
+ metadata.gz: 49a53e90d9387b9fa7dbb83e10e08fcc7650e2e8
4
+ data.tar.gz: af2fecfe830084869b34bd41b6b2077b5ec4218a
5
5
  SHA512:
6
- metadata.gz: 0a3c08d240af88c8d31a163839ce6e3c29630d41caeb9e47d1bed53cd8a1a548128e75e5174d6ff7032eb6d29a12143f534a1564855dccef6c4c6a0ac611bcce
7
- data.tar.gz: 1bc41d6970b43675ca5a00fe8411335cff168c99b2aa54c77aea3f5d2c8796e6db8f95af50a716a737b35b89a30237812912d05d8db403f194745539c8d6a104
6
+ metadata.gz: fa011122b74d076892ae48198f56b71ab809f20bdca8d56c1a0754ccd7711c03093bcd6721b6b15aedd4599ede040ccb3d23d4947dbf4748f7531b5e68f0e5bb
7
+ data.tar.gz: 2507b667f71982f46c181a4b0ae8c55f94a2d01338f035a98e0df38ff18639b39a957bbd754c6b481e61c0a95f446e16e157e4b9562c1551f2696651c7ef22f0
@@ -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)
@@ -88,7 +91,7 @@ module MiniMagick
88
91
 
89
92
  ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon
90
93
 
91
- Kernel.open(path_or_url, "rb") do |file|
94
+ Kernel.open(path_or_url, "rb", options) do |file|
92
95
  read(file, ext)
93
96
  end
94
97
  end
@@ -343,11 +346,14 @@ module MiniMagick
343
346
  #
344
347
  # @return [Array] Matrix of each color of each pixel
345
348
  def get_pixels
346
- output = MiniMagick::Tool::Convert.new do |convert|
347
- convert << path
348
- convert.depth(8)
349
- convert << "RGB:-"
350
- end
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)
351
357
 
352
358
  pixels_array = output.unpack("C*")
353
359
  pixels = pixels_array.each_slice(3).each_slice(width).to_a
@@ -555,13 +561,7 @@ module MiniMagick
555
561
  end
556
562
 
557
563
  def mogrify(page = nil)
558
- MiniMagick::Tool::Mogrify.new do |builder|
559
- builder.instance_eval do
560
- def format(*args)
561
- fail NoMethodError,
562
- "you must call #format on a MiniMagick::Image directly"
563
- end
564
- end
564
+ MiniMagick::Tool::MogrifyRestricted.new do |builder|
565
565
  yield builder if block_given?
566
566
  builder << (page ? "#{path}[#{page}]" : path)
567
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
@@ -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.strip
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"
@@ -8,8 +8,8 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 7
12
- TINY = 1
11
+ MINOR = 8
12
+ TINY = 0
13
13
  PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
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.7.1
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-06-15 00:00:00.000000000 Z
16
+ date: 2017-07-06 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
@@ -129,6 +129,7 @@ files:
129
129
  - lib/mini_magick/tool/identify.rb
130
130
  - lib/mini_magick/tool/import.rb
131
131
  - lib/mini_magick/tool/mogrify.rb
132
+ - lib/mini_magick/tool/mogrify_restricted.rb
132
133
  - lib/mini_magick/tool/montage.rb
133
134
  - lib/mini_magick/tool/stream.rb
134
135
  - lib/mini_magick/utilities.rb