mini_magick 4.9.5 → 4.11.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
  SHA256:
3
- metadata.gz: 66e2c6af6925e0ecc26c917f270ff575986489977416754ecc89db3bbab04dee
4
- data.tar.gz: cac982bbd12f543f637dce9a6fc8ed9e6c2139f7010d9da82f53a510ef2e2525
3
+ metadata.gz: f97cb0365a2a45cdb41c9091a4339fdd75a37cdb041c454cab800fd9464f5c0f
4
+ data.tar.gz: b5f97721ee2657631def0e8c498f257639e126a3ad745688356ae5a15ff5de9f
5
5
  SHA512:
6
- metadata.gz: 03d841baabdc47d95a763010f113cfbc6d0acdf1ca8894e16c80bb86e307516b0f00da4c55617e5207360e4eb7bbb1e5268f5da62dabd4eb291da3d029354fdf
7
- data.tar.gz: 201f2187bedeb2db3157f15f611c026216b083b1e0174c67389a3a157976c0b887e211fc1e6bd2286736f27f04940f6c29586fd00d5079b6c2573e38a1739da4
6
+ metadata.gz: 5339cf648a6cdc78f5a115e03ab77ec3f61bd83de5fcea0638ccb354e9b03b4c29e59b31e6681da9e1a238b2bee73b2a460ed5db0989eca90c097f29a9b0ebb5
7
+ data.tar.gz: 53b55f439ac4172e68e82c20e67a357160303fc3c382c0d7bb4bfeb4ba1e3e469b95ff89c517ab15f0c67436ab1c831fee5d7e88d0e981876cbc059b5c7dfad6
@@ -4,14 +4,6 @@ require 'logger'
4
4
  module MiniMagick
5
5
  module Configuration
6
6
 
7
- ##
8
- # Set whether you want to use [ImageMagick](http://www.imagemagick.org) or
9
- # [GraphicsMagick](http://www.graphicsmagick.org).
10
- #
11
- # @return [Symbol] `:imagemagick`, `:imagemagick7`, or `:graphicsmagick`
12
- #
13
- attr_accessor :cli
14
-
15
7
  ##
16
8
  # If you don't have the CLI tools in your PATH, you can set the path to the
17
9
  # executables.
@@ -110,9 +102,9 @@ module MiniMagick
110
102
  end
111
103
 
112
104
  CLI_DETECTION = {
105
+ imagemagick7: "magick",
113
106
  imagemagick: "mogrify",
114
107
  graphicsmagick: "gm",
115
- imagemagick7: "magick",
116
108
  }
117
109
 
118
110
  # @private (for backwards compatibility)
@@ -42,7 +42,7 @@ module MiniMagick
42
42
 
43
43
  def cheap_info(value)
44
44
  @info.fetch(value) do
45
- format, width, height, size = self["%m %w %h %b"].split(" ")
45
+ format, width, height, size = parse_warnings(self["%m %w %h %b"]).split(" ")
46
46
 
47
47
  path = @path
48
48
  path = path.match(/\[\d+\]$/).pre_match if path =~ /\[\d+\]$/
@@ -61,6 +61,16 @@ module MiniMagick
61
61
  rescue ArgumentError, TypeError
62
62
  raise MiniMagick::Invalid, "image data can't be read"
63
63
  end
64
+
65
+ def parse_warnings(raw_info)
66
+ return raw_info unless raw_info.split("\n").size > 1
67
+
68
+ raw_info.split("\n").each do |line|
69
+ # must match "%m %w %h %b"
70
+ return line if line.match? /^[A-Z]+ \d+ \d+ \d+B$/
71
+ end
72
+ raise TypeError
73
+ end
64
74
 
65
75
  def colorspace
66
76
  @info["colorspace"] ||= self["%r"]
@@ -15,7 +15,7 @@ module MiniMagick
15
15
  # methods.
16
16
  #
17
17
  # Use this to pass in a stream object. Must respond to #read(size) or be a
18
- # binary string object (BLOBBBB)
18
+ # binary string object (BLOB)
19
19
  #
20
20
  # Probably easier to use the {.open} method if you want to open a file or a
21
21
  # URL.
@@ -102,7 +102,11 @@ module MiniMagick
102
102
  end
103
103
  ext.sub!(/:.*/, '') # hack for filenames or URLs that include a colon
104
104
 
105
- openable.open(options) { |file| read(file, ext) }
105
+ if openable.is_a?(URI::Generic)
106
+ openable.open(options) { |file| read(file, ext) }
107
+ else
108
+ openable.open(**options) { |file| read(file, ext) }
109
+ end
106
110
  end
107
111
 
108
112
  ##
@@ -374,6 +378,23 @@ module MiniMagick
374
378
  pixels
375
379
  end
376
380
 
381
+ ##
382
+ # This is used to create image from pixels. This might be required if you
383
+ # create pixels for some image processing reasons and you want to form
384
+ # image from those pixels.
385
+ #
386
+ # *DANGER*: This operation can be very expensive. Please try to use with
387
+ # caution.
388
+ #
389
+ # @example
390
+ # # It is given in readme.md file
391
+ ##
392
+ def self.get_image_from_pixels(pixels, dimension, map, depth, mime_type)
393
+ pixels = pixels.flatten
394
+ blob = pixels.pack('C*')
395
+ import_pixels(blob, *dimension, depth, map, mime_type)
396
+ end
397
+
377
398
  ##
378
399
  # This is used to change the format of the image. That is, from "tiff to
379
400
  # jpg" or something like that. Once you run it, the instance is pointing to
@@ -583,5 +604,31 @@ module MiniMagick
583
604
  def layer?
584
605
  path =~ /\[\d+\]$/
585
606
  end
607
+
608
+ ##
609
+ # Compares if image width
610
+ # is greater than height
611
+ # ============
612
+ # | |
613
+ # | |
614
+ # ============
615
+ # @return [Boolean]
616
+ def landscape?
617
+ width > height
618
+ end
619
+
620
+ ##
621
+ # Compares if image height
622
+ # is greater than width
623
+ # ======
624
+ # | |
625
+ # | |
626
+ # | |
627
+ # | |
628
+ # ======
629
+ # @return [Boolean]
630
+ def portrait?
631
+ height > width
632
+ end
586
633
  end
587
634
  end
@@ -44,8 +44,10 @@ module MiniMagick
44
44
  # @private
45
45
  attr_reader :name, :args
46
46
 
47
- # @param whiny [Boolean] Whether to raise errors on exit codes different
48
- # than 0.
47
+ # @param name [String]
48
+ # @param options [Hash]
49
+ # @option options [Boolean] :whiny Whether to raise errors on non-zero
50
+ # exit codes.
49
51
  # @example
50
52
  # MiniMagick::Tool::Identify.new(whiny: false) do |identify|
51
53
  # identify.help # returns exit status 1, which would otherwise throw an error
@@ -190,9 +192,15 @@ module MiniMagick
190
192
  # end
191
193
  # # executes `convert wand.gif \( wizard.gif -rotate 30 \) +append images.gif`
192
194
  #
193
- def stack
195
+ def stack(*args)
194
196
  self << "("
195
- yield self
197
+ args.each do |value|
198
+ case value
199
+ when Hash then value.each { |key, value| send(key, *value) }
200
+ when String then self << value
201
+ end
202
+ end
203
+ yield self if block_given?
196
204
  self << ")"
197
205
  end
198
206
 
@@ -227,6 +235,7 @@ module MiniMagick
227
235
  ##
228
236
  # Define creator operator methods
229
237
  #
238
+ # @example
230
239
  # mogrify = MiniMagick::Tool.new("mogrify")
231
240
  # mogrify.canvas("khaki")
232
241
  # mogrify.command.join(" ") #=> "mogrify canvas:khaki"
@@ -251,10 +260,11 @@ module MiniMagick
251
260
  ##
252
261
  # Any undefined method will be transformed into a CLI option
253
262
  #
263
+ # @example
254
264
  # mogrify = MiniMagick::Tool.new("mogrify")
255
265
  # mogrify.adaptive_blur("...")
256
266
  # mogrify.foo_bar
257
- # mogrify.command.join(" ") "mogrify -adaptive-blur ... -foo-bar"
267
+ # mogrify.command.join(" ") # => "mogrify -adaptive-blur ... -foo-bar"
258
268
  #
259
269
  def method_missing(name, *args)
260
270
  option = "-#{name.to_s.tr('_', '-')}"
@@ -8,8 +8,8 @@ module MiniMagick
8
8
 
9
9
  module VERSION
10
10
  MAJOR = 4
11
- MINOR = 9
12
- TINY = 5
11
+ MINOR = 11
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.9.5
4
+ version: 4.11.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: 2019-07-18 00:00:00.000000000 Z
16
+ date: 2020-11-06 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: rake
@@ -147,7 +147,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
147
147
  requirements:
148
148
  - - ">="
149
149
  - !ruby/object:Gem::Version
150
- version: '0'
150
+ version: '2.0'
151
151
  required_rubygems_version: !ruby/object:Gem::Requirement
152
152
  requirements:
153
153
  - - ">="
@@ -155,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
155
  version: '0'
156
156
  requirements:
157
157
  - You must have ImageMagick or GraphicsMagick installed
158
- rubygems_version: 3.0.3
158
+ rubygems_version: 3.1.4
159
159
  signing_key:
160
160
  specification_version: 4
161
161
  summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick