mini_magick 4.10.1 → 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 +4 -4
- data/lib/mini_magick/configuration.rb +0 -8
- data/lib/mini_magick/image.rb +18 -1
- data/lib/mini_magick/image/info.rb +11 -1
- data/lib/mini_magick/tool.rb +15 -5
- data/lib/mini_magick/version.rb +2 -2
- metadata +3 -4
- data/lib/mini_magick/immutable_image.rb +0 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f97cb0365a2a45cdb41c9091a4339fdd75a37cdb041c454cab800fd9464f5c0f
|
4
|
+
data.tar.gz: b5f97721ee2657631def0e8c498f257639e126a3ad745688356ae5a15ff5de9f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
data/lib/mini_magick/image.rb
CHANGED
@@ -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 (
|
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.
|
@@ -378,6 +378,23 @@ module MiniMagick
|
|
378
378
|
pixels
|
379
379
|
end
|
380
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
|
+
|
381
398
|
##
|
382
399
|
# This is used to change the format of the image. That is, from "tiff to
|
383
400
|
# jpg" or something like that. Once you run it, the instance is pointing to
|
@@ -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"]
|
data/lib/mini_magick/tool.rb
CHANGED
@@ -44,8 +44,10 @@ module MiniMagick
|
|
44
44
|
# @private
|
45
45
|
attr_reader :name, :args
|
46
46
|
|
47
|
-
# @param
|
48
|
-
#
|
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
|
-
|
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('_', '-')}"
|
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.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: 2020-
|
16
|
+
date: 2020-11-06 00:00:00.000000000 Z
|
17
17
|
dependencies:
|
18
18
|
- !ruby/object:Gem::Dependency
|
19
19
|
name: rake
|
@@ -118,7 +118,6 @@ files:
|
|
118
118
|
- lib/mini_magick/configuration.rb
|
119
119
|
- lib/mini_magick/image.rb
|
120
120
|
- lib/mini_magick/image/info.rb
|
121
|
-
- lib/mini_magick/immutable_image.rb
|
122
121
|
- lib/mini_magick/shell.rb
|
123
122
|
- lib/mini_magick/tool.rb
|
124
123
|
- lib/mini_magick/tool/animate.rb
|
@@ -156,7 +155,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
155
|
version: '0'
|
157
156
|
requirements:
|
158
157
|
- You must have ImageMagick or GraphicsMagick installed
|
159
|
-
rubygems_version: 3.1.
|
158
|
+
rubygems_version: 3.1.4
|
160
159
|
signing_key:
|
161
160
|
specification_version: 4
|
162
161
|
summary: Manipulate images with minimal use of memory via ImageMagick / GraphicsMagick
|
@@ -1,18 +0,0 @@
|
|
1
|
-
module MiniMagick
|
2
|
-
class Image
|
3
|
-
def initialize(source)
|
4
|
-
if source.is_a?(String) || source.is_a?(Pathname)
|
5
|
-
@source_path = source.to_s
|
6
|
-
elsif source.respond_to?(:path)
|
7
|
-
@source_path = source.path
|
8
|
-
else
|
9
|
-
fail ArgumentError, "invalid source object: #{source.inspect} (expected String, Pathname or #path)"
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
def method_missing
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
image = MiniMagick::Image.new()
|