rmagick 7.0.5 → 7.1.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/CHANGELOG.md +39 -0
- data/Rakefile +6 -0
- data/ext/RMagick/extconf.rb +2 -2
- data/ext/RMagick/rmagick.cpp +26 -4
- data/ext/RMagick/rmagick.h +5 -3
- data/ext/RMagick/rmdraw.cpp +15 -45
- data/ext/RMagick/rmenum.cpp +5 -5
- data/ext/RMagick/rmilist.cpp +102 -24
- data/ext/RMagick/rmimage.cpp +102 -55
- data/ext/RMagick/rminfo.cpp +11 -3
- data/ext/RMagick/rmkinfo.cpp +1 -1
- data/ext/RMagick/rmmain.cpp +3 -2
- data/ext/RMagick/rmmontage.cpp +1 -1
- data/ext/RMagick/rmpixel.cpp +4 -4
- data/ext/RMagick/rmutil.cpp +44 -10
- data/lib/rmagick/version.rb +1 -1
- data/lib/rmagick_internal.rb +13 -7
- data/lib/rvg/embellishable.rb +8 -1
- data/lib/rvg/misc.rb +3 -22
- data/lib/rvg/stylable.rb +2 -2
- data/sig/rmagick/_image_common_methods.rbs +1 -0
- data/sig/rvg/misc.rbs +0 -1
- metadata +2 -2
data/ext/RMagick/rmutil.cpp
CHANGED
|
@@ -338,6 +338,36 @@ rm_str2cstr(VALUE str, size_t *len)
|
|
|
338
338
|
}
|
|
339
339
|
|
|
340
340
|
|
|
341
|
+
/**
|
|
342
|
+
* Same as rm_str2cstr, but for arguments that name a file. Use this one for a
|
|
343
|
+
* pathname and rm_str2cstr for a blob.
|
|
344
|
+
*
|
|
345
|
+
* ImageMagick keeps a pathname in a fixed-size buffer and reads it back as a
|
|
346
|
+
* NUL-terminated C string, so a NUL byte in the middle of the argument would
|
|
347
|
+
* cut the pathname short and the file opened or created would not be the one
|
|
348
|
+
* the caller named. Ruby's own file methods reject such a pathname; going
|
|
349
|
+
* through StringValueCStr makes these do the same.
|
|
350
|
+
*
|
|
351
|
+
* No Ruby usage (internal function)
|
|
352
|
+
*
|
|
353
|
+
* @param str the Ruby string
|
|
354
|
+
* @param len pointer to a size_t in which to store the number of characters
|
|
355
|
+
* @return a C string version of str
|
|
356
|
+
* @throw ArgumentError if str contains a NUL byte
|
|
357
|
+
*/
|
|
358
|
+
char *
|
|
359
|
+
rm_path2cstr(VALUE str, size_t *len)
|
|
360
|
+
{
|
|
361
|
+
char *path = StringValueCStr(str);
|
|
362
|
+
|
|
363
|
+
if (len)
|
|
364
|
+
{
|
|
365
|
+
*len = (size_t)RSTRING_LEN(str);
|
|
366
|
+
}
|
|
367
|
+
return path;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
|
|
341
371
|
/**
|
|
342
372
|
* Called when `rb_str_to_str' raises an exception.
|
|
343
373
|
*
|
|
@@ -509,7 +539,7 @@ rm_fuzz_to_dbl(VALUE fuzz_arg)
|
|
|
509
539
|
|
|
510
540
|
|
|
511
541
|
/**
|
|
512
|
-
* Convert
|
|
542
|
+
* Convert an application-supplied number to a Quantum. If the object is a Float,
|
|
513
543
|
* truncate it before converting.
|
|
514
544
|
*
|
|
515
545
|
* No Ruby usage (internal function)
|
|
@@ -706,7 +736,7 @@ rm_set_magickpixel(MagickPixel *pp, const char *color)
|
|
|
706
736
|
* No Ruby usage (internal function)
|
|
707
737
|
*
|
|
708
738
|
* Notes:
|
|
709
|
-
* - The `temp_name' argument must point to
|
|
739
|
+
* - The `temp_name' argument must point to a char array of size
|
|
710
740
|
* MaxTextExtent.
|
|
711
741
|
*
|
|
712
742
|
* @param image the image
|
|
@@ -785,7 +815,7 @@ rm_delete_temp_image(char *temp_name)
|
|
|
785
815
|
* - This funky technique allows me to safely add additional information to
|
|
786
816
|
* the ImageMagickError object in both 1.6.8 and 1.8.0.
|
|
787
817
|
*
|
|
788
|
-
* @param msg the error
|
|
818
|
+
* @param msg the error message
|
|
789
819
|
* @throw ImageMagickError
|
|
790
820
|
* @see www.ruby_talk.org/36408.
|
|
791
821
|
*/
|
|
@@ -937,7 +967,10 @@ void rm_set_user_artifact(Image *images, Info *info)
|
|
|
937
967
|
image = GetFirstImageInList(images);
|
|
938
968
|
while (image)
|
|
939
969
|
{
|
|
940
|
-
SetImageArtifact(image, "user", value)
|
|
970
|
+
if (!SetImageArtifact(image, "user", value))
|
|
971
|
+
{
|
|
972
|
+
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
|
973
|
+
}
|
|
941
974
|
image = GetNextImageInList(image);
|
|
942
975
|
}
|
|
943
976
|
}
|
|
@@ -990,7 +1023,6 @@ rm_get_optional_arguments(VALUE img)
|
|
|
990
1023
|
*/
|
|
991
1024
|
static void copy_options(Image *image, Info *info)
|
|
992
1025
|
{
|
|
993
|
-
char property[MaxTextExtent];
|
|
994
1026
|
const char *option;
|
|
995
1027
|
|
|
996
1028
|
ResetImageOptionIterator(info);
|
|
@@ -1001,8 +1033,10 @@ static void copy_options(Image *image, Info *info)
|
|
|
1001
1033
|
value = GetImageOption(info, option);
|
|
1002
1034
|
if (value)
|
|
1003
1035
|
{
|
|
1004
|
-
|
|
1005
|
-
|
|
1036
|
+
if (!SetImageArtifact(image, option, value))
|
|
1037
|
+
{
|
|
1038
|
+
rb_raise(rb_eNoMemError, "not enough memory to continue");
|
|
1039
|
+
}
|
|
1006
1040
|
}
|
|
1007
1041
|
}
|
|
1008
1042
|
}
|
|
@@ -1483,7 +1517,7 @@ rm_clone_image(Image *image)
|
|
|
1483
1517
|
|
|
1484
1518
|
|
|
1485
1519
|
/**
|
|
1486
|
-
* Remove the ImageMagick links between images in
|
|
1520
|
+
* Remove the ImageMagick links between images in a scene sequence.
|
|
1487
1521
|
*
|
|
1488
1522
|
* No Ruby usage (internal function)
|
|
1489
1523
|
*
|
|
@@ -1569,7 +1603,7 @@ rm_check_image_exception(Image *imglist, ErrorRetention retention)
|
|
|
1569
1603
|
* @param severity information about the severity of the error
|
|
1570
1604
|
* @param reason the reason for the error
|
|
1571
1605
|
* @param description description of the error
|
|
1572
|
-
* @param msg the buffer where the exception message should be
|
|
1606
|
+
* @param msg the buffer where the exception message should be formatted in
|
|
1573
1607
|
*/
|
|
1574
1608
|
static void
|
|
1575
1609
|
format_exception(const ExceptionType severity, const char *reason, const char *description, char *msg)
|
|
@@ -1625,7 +1659,7 @@ rm_warning_handler(const ExceptionType severity, const char *reason, const char
|
|
|
1625
1659
|
|
|
1626
1660
|
|
|
1627
1661
|
/**
|
|
1628
|
-
* Called from ImageMagick for
|
|
1662
|
+
* Called from ImageMagick for an error.
|
|
1629
1663
|
*
|
|
1630
1664
|
* No Ruby usage (internal function)
|
|
1631
1665
|
*
|
data/lib/rmagick/version.rb
CHANGED
data/lib/rmagick_internal.rb
CHANGED
|
@@ -151,7 +151,7 @@ module Magick
|
|
|
151
151
|
end
|
|
152
152
|
|
|
153
153
|
class Draw
|
|
154
|
-
#
|
|
154
|
+
# These hashes are used to map Magick constant
|
|
155
155
|
# values to the strings used in the primitives.
|
|
156
156
|
ALIGN_TYPE_NAMES = {
|
|
157
157
|
LeftAlign.to_i => 'left',
|
|
@@ -217,10 +217,13 @@ module Magick
|
|
|
217
217
|
|
|
218
218
|
def enquote(str)
|
|
219
219
|
str = to_string(str)
|
|
220
|
-
|
|
220
|
+
# escape existing backslashes, so that they cannot escape the delimiter
|
|
221
|
+
# added below and let the rest of the string be parsed as MVG
|
|
222
|
+
str = str.gsub('\\') { |b| '\\' + b }
|
|
223
|
+
if str.length > 2 && /\A(?:"[^"\\]+"|'[^'\\]+'|\{[^}\\]+\})\z/.match(str)
|
|
221
224
|
str
|
|
222
225
|
else
|
|
223
|
-
'"' + str + '"'
|
|
226
|
+
'"' + str.gsub('"') { |c| '\\' + c } + '"'
|
|
224
227
|
end
|
|
225
228
|
end
|
|
226
229
|
|
|
@@ -282,7 +285,7 @@ module Magick
|
|
|
282
285
|
|
|
283
286
|
# Invoke a clip-path defined by def_clip_path.
|
|
284
287
|
def clip_path(name)
|
|
285
|
-
primitive "clip-path #{
|
|
288
|
+
primitive "clip-path #{enquote(name)}"
|
|
286
289
|
end
|
|
287
290
|
|
|
288
291
|
# Define the clipping rule.
|
|
@@ -343,7 +346,7 @@ module Magick
|
|
|
343
346
|
# Let anything through, but the only defined argument
|
|
344
347
|
# is "UTF-8". All others are apparently ignored.
|
|
345
348
|
def encoding(encoding)
|
|
346
|
-
primitive "encoding #{
|
|
349
|
+
primitive "encoding #{enquote(encoding)}"
|
|
347
350
|
end
|
|
348
351
|
|
|
349
352
|
# Specify object fill, a color name or pattern name
|
|
@@ -612,7 +615,10 @@ module Magick
|
|
|
612
615
|
def text(x, y, text)
|
|
613
616
|
text = to_string(text)
|
|
614
617
|
Kernel.raise ArgumentError, 'missing text argument' if text.empty?
|
|
615
|
-
|
|
618
|
+
# escape existing backslashes, so that they cannot escape the delimiter
|
|
619
|
+
# added below and let the rest of the string be parsed as MVG
|
|
620
|
+
text = text.gsub('\\') { |b| '\\' + b }
|
|
621
|
+
if text.length > 2 && /\A(?:"[^"\\]+"|'[^'\\]+'|\{[^}\\]+\})\z/.match(text)
|
|
616
622
|
# text already quoted
|
|
617
623
|
elsif !text['\'']
|
|
618
624
|
text = '\'' + text + '\''
|
|
@@ -799,7 +805,7 @@ module Magick
|
|
|
799
805
|
def color_reset!(fill)
|
|
800
806
|
save = background_color
|
|
801
807
|
# Change the background color _outside_ the begin block
|
|
802
|
-
# so that if this object is frozen the
|
|
808
|
+
# so that if this object is frozen the exception will be
|
|
803
809
|
# raised before we have to handle it explicitly.
|
|
804
810
|
self.background_color = fill
|
|
805
811
|
begin
|
data/lib/rvg/embellishable.rb
CHANGED
|
@@ -66,8 +66,15 @@ module Magick
|
|
|
66
66
|
# Use the RVG::ShapeConstructors#path method to create Path objects in a container.
|
|
67
67
|
def initialize(path)
|
|
68
68
|
super()
|
|
69
|
+
path = path.to_s
|
|
70
|
+
# SVG path data is command letters, numbers, commas and whitespace only.
|
|
71
|
+
# Anything else could close the MVG token that Draw#path wraps this in
|
|
72
|
+
# and have the rest of the string executed as further MVG primitives.
|
|
73
|
+
invalid = path[/[^MmZzLlHhVvCcSsQqTtAa0-9eE.,+\-\s]/]
|
|
74
|
+
raise ArgumentError, "invalid character in path data (#{invalid.inspect} given)" if invalid
|
|
75
|
+
|
|
69
76
|
@primitive = :path
|
|
70
|
-
@args = [path
|
|
77
|
+
@args = [path]
|
|
71
78
|
end
|
|
72
79
|
end # class Path
|
|
73
80
|
|
data/lib/rvg/misc.rb
CHANGED
|
@@ -74,25 +74,6 @@ module Magick
|
|
|
74
74
|
@ctx.shadow.affine = @ctx.text_attrs.affine
|
|
75
75
|
end
|
|
76
76
|
|
|
77
|
-
def enquote(text)
|
|
78
|
-
return text if text.length > 2 && /\A(?:"[^"]+"|'[^']+'|\{[^}]+\})\z/.match(text)
|
|
79
|
-
|
|
80
|
-
if !text['\'']
|
|
81
|
-
text = '\'' + text + '\''
|
|
82
|
-
return text
|
|
83
|
-
elsif !text['"']
|
|
84
|
-
text = '"' + text + '"'
|
|
85
|
-
return text
|
|
86
|
-
elsif !(text['{'] || text['}'])
|
|
87
|
-
text = '{' + text + '}'
|
|
88
|
-
return text
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
# escape existing braces, surround with braces
|
|
92
|
-
text.gsub!(/[}]/) { |b| '\\' + b }
|
|
93
|
-
'{' + text + '}'
|
|
94
|
-
end
|
|
95
|
-
|
|
96
77
|
def glyph_metrics(glyph_orientation, glyph)
|
|
97
78
|
gm = @ctx.shadow.get_type_metrics('a' + glyph + 'a')
|
|
98
79
|
gm2 = @ctx.shadow.get_type_metrics('aa')
|
|
@@ -151,13 +132,13 @@ module Magick
|
|
|
151
132
|
|
|
152
133
|
def render_glyph(glyph_orientation, x, y, glyph)
|
|
153
134
|
if glyph_orientation.zero?
|
|
154
|
-
@ctx.gc.text(x, y,
|
|
135
|
+
@ctx.gc.text(x, y, glyph)
|
|
155
136
|
else
|
|
156
137
|
@ctx.gc.push
|
|
157
138
|
@ctx.gc.translate(x, y)
|
|
158
139
|
@ctx.gc.rotate(glyph_orientation)
|
|
159
140
|
@ctx.gc.translate(-x, -y)
|
|
160
|
-
@ctx.gc.text(x, y,
|
|
141
|
+
@ctx.gc.text(x, y, glyph)
|
|
161
142
|
@ctx.gc.pop
|
|
162
143
|
end
|
|
163
144
|
end
|
|
@@ -295,7 +276,7 @@ module Magick
|
|
|
295
276
|
# Handle "easy" text
|
|
296
277
|
class DefaultTextStrategy < TextStrategy
|
|
297
278
|
def render(x, y, text)
|
|
298
|
-
@ctx.gc.text(x, y,
|
|
279
|
+
@ctx.gc.text(x, y, text)
|
|
299
280
|
tm = @ctx.shadow.get_type_metrics(text)
|
|
300
281
|
dx = case @ctx.text_attrs.text_anchor
|
|
301
282
|
when :start
|
data/lib/rvg/stylable.rb
CHANGED
|
@@ -80,10 +80,10 @@ module Magick
|
|
|
80
80
|
# the hash keys. The style names and values are:
|
|
81
81
|
# [:baseline_shift] modify the text baseline
|
|
82
82
|
# [:clip_path] clipping path defined by clip_path
|
|
83
|
-
# [:clip_rule] 'evenodd' or '
|
|
83
|
+
# [:clip_rule] 'evenodd' or 'nonzero'
|
|
84
84
|
# [:fill] color name
|
|
85
85
|
# [:fill_opacity] the fill opacity, 0.0<=N<=1.0
|
|
86
|
-
# [:fill_rule] 'evenodd' or '
|
|
86
|
+
# [:fill_rule] 'evenodd' or 'nonzero'
|
|
87
87
|
# [:font] font name or font file name
|
|
88
88
|
# [:font_family] font family name, ex. 'serif'
|
|
89
89
|
# [:font_size] font size in points
|
|
@@ -147,6 +147,7 @@ module Magick
|
|
|
147
147
|
def alpha: () -> bool
|
|
148
148
|
| (AlphaChannelOption value) -> AlphaChannelOption
|
|
149
149
|
def alpha?: () -> bool
|
|
150
|
+
def artifact: (string artifact) -> String?
|
|
150
151
|
def auto_gamma_channel: (*ChannelType channel) -> Image
|
|
151
152
|
def auto_level_channel: (*ChannelType channel) -> Image
|
|
152
153
|
def auto_orient: () -> Image
|
data/sig/rvg/misc.rbs
CHANGED
|
@@ -24,7 +24,6 @@ module Magick
|
|
|
24
24
|
@ctx: GraphicContext
|
|
25
25
|
|
|
26
26
|
def initialize: (GraphicContext context) -> void
|
|
27
|
-
def enquote: (String text) -> String
|
|
28
27
|
def glyph_metrics: (Integer | Float glyph_orientation, string glyph) -> [Integer | Float, Integer | Float]
|
|
29
28
|
def text_rel_coords: (string text) -> [Array[Integer | Float], Array[Integer | Float]]
|
|
30
29
|
def shift_baseline: (Integer | Float glyph_orientation, string glyph) -> (Integer | Float)
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rmagick
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 7.0
|
|
4
|
+
version: 7.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tim Hunter
|
|
@@ -143,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
143
143
|
version: '0'
|
|
144
144
|
requirements:
|
|
145
145
|
- ImageMagick 6.9.0+ (for ImageMagick 6) or 7.1.0+ (for ImageMagick 7)
|
|
146
|
-
rubygems_version: 4.0.
|
|
146
|
+
rubygems_version: 4.0.16
|
|
147
147
|
specification_version: 4
|
|
148
148
|
summary: Ruby binding to ImageMagick
|
|
149
149
|
test_files: []
|