rmagick 4.2.2 → 5.3.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -29,47 +29,276 @@
29
29
  #define magick_module module
30
30
  #endif
31
31
 
32
- /** Method that effects an image */
33
- typedef Image *(effector_t)(const Image *, const double, const double, ExceptionInfo *);
34
- /** Method that flips an image */
35
- typedef Image *(flipper_t)(const Image *, ExceptionInfo *);
36
- /** Method that magnifies an image */
37
- typedef Image *(magnifier_t)(const Image *, ExceptionInfo *);
38
- /** Method that reads an image */
39
- typedef Image *(reader_t)(const Info *, ExceptionInfo *);
40
- /** Method that scales an image */
41
- typedef Image *(scaler_t)(const Image *, const size_t, const size_t, ExceptionInfo *);
42
- /** Method that computes threshold on an image */
43
- #if defined(IMAGEMAGICK_7)
44
- typedef MagickBooleanType (auto_channel_t)(Image *, ExceptionInfo *exception);
45
- typedef Image *(channel_method_t)(const Image *, const double, const double, ExceptionInfo *);
46
- typedef MagickBooleanType (thresholder_t)(Image *, const char *, ExceptionInfo *);
47
- #else
48
- typedef MagickBooleanType (auto_channel_t)(Image *, const ChannelType);
49
- typedef Image *(channel_method_t)(const Image *, const ChannelType, const double, const double, ExceptionInfo *);
50
- typedef MagickBooleanType (thresholder_t)(Image *, const char *);
51
- #define IsEquivalentImage IsImageSimilar
52
- #define OrderedDitherImage OrderedPosterizeImage
53
- #endif
54
- /** Method that transforms an image */
55
- typedef Image *(xformer_t)(const Image *, const RectangleInfo *, ExceptionInfo *);
56
-
57
32
  static VALUE cropper(int, int, VALUE *, VALUE);
58
- static VALUE effect_image(VALUE, int, VALUE *, effector_t);
59
- static VALUE flipflop(int, VALUE, flipper_t);
60
- static VALUE rd_image(VALUE, VALUE, reader_t);
33
+ static VALUE effect_image(VALUE, int, VALUE *, gvl_function_t);
34
+ static VALUE flipflop(int, VALUE, gvl_function_t);
35
+ static VALUE rd_image(VALUE, VALUE, gvl_function_t);
61
36
  static VALUE rotate(int, int, VALUE *, VALUE);
62
- static VALUE scale(int, int, VALUE *, VALUE, scaler_t);
63
- static VALUE threshold_image(int, VALUE *, VALUE, thresholder_t);
64
- static VALUE xform_image(int, VALUE, VALUE, VALUE, VALUE, VALUE, xformer_t);
37
+ static VALUE scale(int, int, VALUE *, VALUE, gvl_function_t);
38
+ static VALUE threshold_image(int, VALUE *, VALUE, gvl_function_t);
39
+ static VALUE xform_image(int, VALUE, VALUE, VALUE, VALUE, VALUE, gvl_function_t);
65
40
  static VALUE array_from_images(Image *);
66
- static void call_trace_proc(Image *, const char *);
67
41
  static VALUE file_arg_rescue(VALUE, VALUE ATTRIBUTE_UNUSED) ATTRIBUTE_NORETURN;
68
- static VALUE rm_trace_creation_handle_exception(VALUE, VALUE) ATTRIBUTE_NORETURN;
42
+ static size_t rm_image_memsize(const void *img);
43
+
44
+ const rb_data_type_t rm_image_data_type = {
45
+ "Magick::Image",
46
+ { NULL, rm_image_destroy, rm_image_memsize, },
47
+ 0, 0,
48
+ RUBY_TYPED_FROZEN_SHAREABLE,
49
+ };
69
50
 
70
51
  static const char *BlackPointCompensationKey = "PROFILE:black-point-compensation";
71
52
 
72
53
 
54
+ DEFINE_GVL_STUB4(AdaptiveBlurImage, const Image *, const double, const double, ExceptionInfo *);
55
+ DEFINE_GVL_STUB4(AdaptiveResizeImage, const Image *, const size_t, const size_t, ExceptionInfo *);
56
+ DEFINE_GVL_STUB4(AdaptiveSharpenImage, const Image *, const double, const double, ExceptionInfo *);
57
+ DEFINE_GVL_STUB5(AdaptiveThresholdImage, const Image *, const size_t, const size_t, const double, ExceptionInfo *);
58
+ DEFINE_GVL_STUB3(AffineTransformImage, const Image *, const AffineMatrix *, ExceptionInfo *);
59
+ DEFINE_GVL_STUB2(Base64Decode, const char *, size_t *);
60
+ DEFINE_GVL_STUB4(BlobToImage, const ImageInfo *, const void *, const size_t, ExceptionInfo *);
61
+ DEFINE_GVL_STUB3(BlueShiftImage, const Image *, const double, ExceptionInfo *);
62
+ DEFINE_GVL_STUB4(BlurImage, const Image *, const double, const double, ExceptionInfo *);
63
+ DEFINE_GVL_STUB4(CharcoalImage, const Image *, const double, const double, ExceptionInfo *);
64
+ DEFINE_GVL_STUB3(ChopImage, const Image *, const RectangleInfo *, ExceptionInfo *);
65
+ DEFINE_GVL_STUB3(ColorMatrixImage, const Image *, const KernelInfo *, ExceptionInfo *);
66
+ DEFINE_GVL_STUB3(CropImage, const Image *, const RectangleInfo *, ExceptionInfo *);
67
+ DEFINE_GVL_STUB3(DecipherImage, Image *, const char *, ExceptionInfo *);
68
+ DEFINE_GVL_STUB3(DeskewImage, const Image *, const double, ExceptionInfo *);
69
+ DEFINE_GVL_STUB2(DespeckleImage, const Image *, ExceptionInfo *);
70
+ DEFINE_GVL_STUB6(DistortImage, const Image *, DistortMethod, const size_t, const double *, MagickBooleanType, ExceptionInfo *);
71
+ DEFINE_GVL_STUB3(EdgeImage, const Image *, const double, ExceptionInfo *);
72
+ DEFINE_GVL_STUB4(EmbossImage, const Image *, const double, const double, ExceptionInfo *);
73
+ DEFINE_GVL_STUB3(EncipherImage, Image *, const char *, ExceptionInfo *);
74
+ DEFINE_GVL_STUB2(EnhanceImage, const Image *, ExceptionInfo *);
75
+ DEFINE_GVL_STUB3(ExcerptImage, const Image *, const RectangleInfo *, ExceptionInfo *);
76
+ DEFINE_GVL_STUB9(ExportImagePixels, const Image *, const ssize_t, const ssize_t, const size_t, const size_t, const char *, const StorageType, void *, ExceptionInfo *);
77
+ DEFINE_GVL_STUB3(ExtentImage, const Image *, const RectangleInfo *, ExceptionInfo *);
78
+ DEFINE_GVL_STUB2(FlipImage, const Image *, ExceptionInfo *);
79
+ DEFINE_GVL_STUB2(FlopImage, const Image *, ExceptionInfo *);
80
+ DEFINE_GVL_STUB4(GaussianBlurImage, const Image *, const double, const double, ExceptionInfo *);
81
+ DEFINE_GVL_STUB6(GetAuthenticPixels, Image *, const ssize_t, const ssize_t, const size_t, const size_t, ExceptionInfo *);
82
+ DEFINE_GVL_STUB2(GetImageDepth, const Image *, ExceptionInfo *);
83
+ DEFINE_GVL_STUB3(GetImageHistogram, const Image *, size_t *, ExceptionInfo *);
84
+ DEFINE_GVL_STUB3(GetNumberColors, const Image *, FILE *, ExceptionInfo *);
85
+ DEFINE_GVL_STUB6(GetVirtualPixels, const Image *, const ssize_t, const ssize_t, const size_t, const size_t, ExceptionInfo *);
86
+ DEFINE_GVL_STUB4(ImageToBlob, const ImageInfo *, Image *, size_t *, ExceptionInfo *);
87
+ DEFINE_GVL_STUB6(LiquidRescaleImage, const Image *, const size_t, const size_t, const double, const double, ExceptionInfo *);
88
+ DEFINE_GVL_STUB2(MagnifyImage, const Image *, ExceptionInfo *);
89
+ DEFINE_GVL_STUB2(MinifyImage, const Image *, ExceptionInfo *);
90
+ DEFINE_GVL_STUB5(MotionBlurImage, const Image *, const double, const double, const double, ExceptionInfo *);
91
+ DEFINE_GVL_STUB2(PingImage, const ImageInfo *, ExceptionInfo *);
92
+ DEFINE_GVL_STUB3(PreviewImage, const Image *, const PreviewType, ExceptionInfo *);
93
+ DEFINE_GVL_STUB2(ReadImage, const ImageInfo *, ExceptionInfo *);
94
+ DEFINE_GVL_STUB4(RollImage, const Image *, const ssize_t, const ssize_t, ExceptionInfo *);
95
+ DEFINE_GVL_STUB3(RotateImage, const Image *, const double, ExceptionInfo *);
96
+ DEFINE_GVL_STUB4(SampleImage, const Image *, const size_t, const size_t, ExceptionInfo *);
97
+ DEFINE_GVL_STUB4(ScaleImage, const Image *, const size_t, const size_t, ExceptionInfo *);
98
+ DEFINE_GVL_STUB3(SepiaToneImage, const Image *, const double, ExceptionInfo *);
99
+ DEFINE_GVL_STUB5(ShadeImage, const Image *, const MagickBooleanType, const double, const double,ExceptionInfo *);
100
+ DEFINE_GVL_STUB6(ShadowImage, const Image *, const double, const double, const ssize_t, const ssize_t, ExceptionInfo *);
101
+ DEFINE_GVL_STUB4(SharpenImage, const Image *, const double, const double, ExceptionInfo *);
102
+ DEFINE_GVL_STUB3(ShaveImage, const Image *, const RectangleInfo *, ExceptionInfo *);
103
+ DEFINE_GVL_STUB4(ShearImage, const Image *, const double, const double, ExceptionInfo *);
104
+ DEFINE_GVL_STUB5(SketchImage, const Image *, const double, const double, const double, ExceptionInfo *);
105
+ DEFINE_GVL_STUB3(SpliceImage, const Image *, const RectangleInfo *, ExceptionInfo *);
106
+ DEFINE_GVL_STUB5(StatisticImage, const Image *, const StatisticType, const size_t, const size_t, ExceptionInfo *);
107
+ DEFINE_GVL_STUB3(SteganoImage, const Image *, const Image *, ExceptionInfo *);
108
+ DEFINE_GVL_STUB3(StereoImage, const Image *, const Image *, ExceptionInfo *);
109
+ DEFINE_GVL_STUB2(SyncAuthenticPixels, Image *, ExceptionInfo *);
110
+ DEFINE_GVL_STUB4(ThumbnailImage, const Image *, const size_t, const size_t, ExceptionInfo *);
111
+ DEFINE_GVL_STUB2(TransposeImage, const Image *, ExceptionInfo *);
112
+ DEFINE_GVL_STUB2(TransverseImage, const Image *, ExceptionInfo *);
113
+ DEFINE_GVL_STUB2(TrimImage, const Image *, ExceptionInfo *);
114
+ DEFINE_GVL_STUB2(UniqueImageColors, const Image *, ExceptionInfo *);
115
+ DEFINE_GVL_STUB6(UnsharpMaskImage, const Image *, const double, const double, const double, const double, ExceptionInfo *);
116
+ DEFINE_GVL_STUB6(VignetteImage, const Image *, const double, const double, const ssize_t, const ssize_t, ExceptionInfo *);
117
+ #if defined(IMAGEMAGICK_7)
118
+ DEFINE_GVL_STUB4(AddNoiseImage, const Image *, const NoiseType, const double, ExceptionInfo *);
119
+ DEFINE_GVL_STUB2(AutoGammaImage, Image *, ExceptionInfo *);
120
+ DEFINE_GVL_STUB2(AutoLevelImage, Image *, ExceptionInfo *);
121
+ DEFINE_GVL_STUB3(BilevelImage, Image *, const double, ExceptionInfo *);
122
+ DEFINE_GVL_STUB3(BlackThresholdImage, Image *, const char *, ExceptionInfo *);
123
+ DEFINE_GVL_STUB4(BorderImage, const Image *, const RectangleInfo *, const CompositeOperator, ExceptionInfo *);
124
+ DEFINE_GVL_STUB4(ClutImage, Image *, const Image *, const PixelInterpolateMethod, ExceptionInfo *);
125
+ DEFINE_GVL_STUB4(ColorizeImage, const Image *, const char *, const PixelInfo *, ExceptionInfo *);
126
+ DEFINE_GVL_STUB5(CompareImages, Image *, const Image *, const MetricType, double *, ExceptionInfo *);
127
+ DEFINE_GVL_STUB7(CompositeImage, Image *, const Image *, const CompositeOperator, const MagickBooleanType, const ssize_t, const ssize_t, ExceptionInfo *);
128
+ DEFINE_GVL_STUB2(CompressImageColormap, Image *, ExceptionInfo *);
129
+ DEFINE_GVL_STUB4(ContrastStretchImage, Image *, const double, const double, ExceptionInfo *);
130
+ DEFINE_GVL_STUB3(ConvolveImage, const Image *, const KernelInfo *, ExceptionInfo *);
131
+ DEFINE_GVL_STUB3(CycleColormapImage, Image *, const ssize_t, ExceptionInfo *);
132
+ DEFINE_GVL_STUB4(DrawAffineImage, Image *, const Image *, const AffineMatrix *, ExceptionInfo *);
133
+ DEFINE_GVL_STUB2(EqualizeImage, Image *, ExceptionInfo *);
134
+ DEFINE_GVL_STUB4(EvaluateImage, Image *, const MagickEvaluateOperator, const double, ExceptionInfo *);
135
+ DEFINE_GVL_STUB7(FloodfillPaintImage, Image *, const DrawInfo *, const PixelInfo *, const ssize_t, const ssize_t, const MagickBooleanType, ExceptionInfo *);
136
+ DEFINE_GVL_STUB4(FrameImage, const Image *, const FrameInfo *, const CompositeOperator, ExceptionInfo *);
137
+ DEFINE_GVL_STUB5(FunctionImage, Image *, const MagickFunction, const size_t, const double *, ExceptionInfo *);
138
+ DEFINE_GVL_STUB3(FxImage, const Image *, const char *, ExceptionInfo *);
139
+ DEFINE_GVL_STUB3(GammaImage, Image *, const double, ExceptionInfo *);
140
+ DEFINE_GVL_STUB5(GetImageDistortion, Image *, const Image *, const MetricType, double *, ExceptionInfo *);
141
+ DEFINE_GVL_STUB3(GetImageEntropy, const Image *, double *, ExceptionInfo *);
142
+ DEFINE_GVL_STUB4(GetImageExtrema, const Image *, size_t *, size_t *, ExceptionInfo *);
143
+ DEFINE_GVL_STUB3(GetImageMask, const Image *, const PixelMask, ExceptionInfo *);
144
+ DEFINE_GVL_STUB4(GetImageMean, const Image *, double *, double *, ExceptionInfo *);
145
+ DEFINE_GVL_STUB4(ImplodeImage, const Image *, const double, const PixelInterpolateMethod, ExceptionInfo *);
146
+ DEFINE_GVL_STUB9(ImportImagePixels, Image *, const ssize_t, const ssize_t, const size_t, const size_t, const char *, const StorageType, const void *, ExceptionInfo *);
147
+ DEFINE_GVL_STUB5(IsEquivalentImage, const Image *, const Image *, ssize_t *, ssize_t *, ExceptionInfo *);
148
+ DEFINE_GVL_STUB5(LevelImage, Image *, const double, const double, const double, ExceptionInfo *);
149
+ DEFINE_GVL_STUB5(LevelImageColors, Image *, const PixelInfo *, const PixelInfo *, const MagickBooleanType, ExceptionInfo *);
150
+ DEFINE_GVL_STUB5(LevelizeImage, Image *, const double, const double, const double, ExceptionInfo *);
151
+ DEFINE_GVL_STUB4(LinearStretchImage, Image *, const double, const double, ExceptionInfo *);
152
+ DEFINE_GVL_STUB3(ModulateImage, Image *, const char *, ExceptionInfo *);
153
+ DEFINE_GVL_STUB5(MorphologyImage, const Image *, const MorphologyMethod, const ssize_t, const KernelInfo *, ExceptionInfo *);
154
+ DEFINE_GVL_STUB3(NegateImage, Image *, const MagickBooleanType, ExceptionInfo *);
155
+ DEFINE_GVL_STUB2(NormalizeImage, Image *, ExceptionInfo *);
156
+ DEFINE_GVL_STUB4(OilPaintImage, const Image *, const double, const double, ExceptionInfo *);
157
+ DEFINE_GVL_STUB5(OpaquePaintImage, Image *, const PixelInfo *, const PixelInfo *, const MagickBooleanType, ExceptionInfo *);
158
+ DEFINE_GVL_STUB3(OrderedDitherImage, Image *, const char *, ExceptionInfo *);
159
+ DEFINE_GVL_STUB6(PolaroidImage, const Image *, const DrawInfo *, const char *, const double, const PixelInterpolateMethod, ExceptionInfo *);
160
+ DEFINE_GVL_STUB4(PosterizeImage, Image *, const size_t, const DitherMethod, ExceptionInfo *);
161
+ DEFINE_GVL_STUB5(ProfileImage, Image *, const char *, const void *, const size_t, ExceptionInfo *);
162
+ DEFINE_GVL_STUB3(QuantizeImage, const QuantizeInfo *, Image *, ExceptionInfo *);
163
+ DEFINE_GVL_STUB4(RaiseImage, Image *, const RectangleInfo *, const MagickBooleanType, ExceptionInfo *);
164
+ DEFINE_GVL_STUB4(RandomThresholdImage, Image *, const double, const double, ExceptionInfo *);
165
+ DEFINE_GVL_STUB4(RemapImage, const QuantizeInfo *, Image *, const Image *, ExceptionInfo *);
166
+ DEFINE_GVL_STUB5(ResampleImage, const Image *, const double, const double, const FilterType, ExceptionInfo *);
167
+ DEFINE_GVL_STUB5(ResizeImage, const Image *, const size_t, const size_t, const FilterType, ExceptionInfo *);
168
+ DEFINE_GVL_STUB6(SegmentImage, Image *, const ColorspaceType, const MagickBooleanType, const double, const double, ExceptionInfo *);
169
+ DEFINE_GVL_STUB5(SelectiveBlurImage, const Image *, const double, const double, const double, ExceptionInfo *);
170
+ DEFINE_GVL_STUB3(SeparateImage, const Image *, const ChannelType, ExceptionInfo *);
171
+ DEFINE_GVL_STUB2(SeparateImages, const Image *, ExceptionInfo *);
172
+ DEFINE_GVL_STUB3(SetImageAlphaChannel, Image *, const AlphaChannelOption, ExceptionInfo *);
173
+ DEFINE_GVL_STUB2(SetImageBackgroundColor, Image *, ExceptionInfo *);
174
+ DEFINE_GVL_STUB3(SetImageDepth, Image *, const size_t, ExceptionInfo *);
175
+ DEFINE_GVL_STUB4(SetImageExtent, Image *, const size_t, const size_t, ExceptionInfo *);
176
+ DEFINE_GVL_STUB4(SetImageMask, Image *, const PixelMask, const Image *, ExceptionInfo *);
177
+ DEFINE_GVL_STUB3(SetImageStorageClass, Image *, const ClassType, ExceptionInfo *);
178
+ DEFINE_GVL_STUB5(SigmoidalContrastImage, Image *, const MagickBooleanType, const double, const double, ExceptionInfo *);
179
+ DEFINE_GVL_STUB2(SignatureImage, Image *, ExceptionInfo *);
180
+ DEFINE_GVL_STUB3(SolarizeImage, Image *, const double, ExceptionInfo *);
181
+ DEFINE_GVL_STUB5(SparseColorImage, const Image *, const SparseColorMethod, const size_t, const double *, ExceptionInfo *);
182
+ DEFINE_GVL_STUB4(SpreadImage, const Image *, const PixelInterpolateMethod, const double, ExceptionInfo *);
183
+ DEFINE_GVL_STUB4(SwirlImage, const Image *, double, const PixelInterpolateMethod, ExceptionInfo *);
184
+ DEFINE_GVL_STUB2(SyncImage, Image *, ExceptionInfo *);
185
+ DEFINE_GVL_STUB4(TintImage, const Image *, const char *, const PixelInfo *, ExceptionInfo *);
186
+ DEFINE_GVL_STUB3(TransformImageColorspace, Image *, const ColorspaceType, ExceptionInfo *);
187
+ DEFINE_GVL_STUB5(TransparentPaintImage, Image *, const PixelInfo *, const Quantum, const MagickBooleanType, ExceptionInfo *);
188
+ DEFINE_GVL_STUB6(TransparentPaintImageChroma, Image *, const PixelInfo *, const PixelInfo *, const Quantum, const MagickBooleanType, ExceptionInfo *);
189
+ DEFINE_GVL_STUB5(WaveImage, const Image *, const double, const double, const PixelInterpolateMethod, ExceptionInfo *);
190
+ DEFINE_GVL_STUB3(WhiteThresholdImage, Image *, const char *, ExceptionInfo *);
191
+ DEFINE_GVL_STUB3(WriteImage, const ImageInfo *, Image *, ExceptionInfo *);
192
+ #else
193
+ DEFINE_GVL_STUB5(AdaptiveBlurImageChannel, const Image *, const ChannelType, const double, const double, ExceptionInfo *);
194
+ DEFINE_GVL_STUB5(AdaptiveSharpenImageChannel, const Image *, const ChannelType, const double, const double, ExceptionInfo *);
195
+ DEFINE_GVL_STUB3(AddNoiseImage, const Image *, const NoiseType, ExceptionInfo *);
196
+ DEFINE_GVL_STUB4(AddNoiseImageChannel, const Image *, const ChannelType, const NoiseType, ExceptionInfo *);
197
+ DEFINE_GVL_STUB2(AutoGammaImageChannel, Image *, const ChannelType);
198
+ DEFINE_GVL_STUB2(AutoLevelImageChannel,Image *, const ChannelType);
199
+ DEFINE_GVL_STUB3(BilevelImageChannel, Image *, const ChannelType,const double);
200
+ DEFINE_GVL_STUB2(BlackThresholdImage, Image *, const char *);
201
+ DEFINE_GVL_STUB5(BlurImageChannel, const Image *, const ChannelType, const double, const double, ExceptionInfo *);
202
+ DEFINE_GVL_STUB3(BorderImage, const Image *, const RectangleInfo *, ExceptionInfo *);
203
+ DEFINE_GVL_STUB3(ClutImageChannel, Image *, const ChannelType, const Image *);
204
+ DEFINE_GVL_STUB4(ColorizeImage, const Image *, const char *, const PixelPacket, ExceptionInfo *);
205
+ DEFINE_GVL_STUB6(CompareImageChannels, Image *, const Image *, const ChannelType, const MetricType, double *, ExceptionInfo *);
206
+ DEFINE_GVL_STUB5(CompositeImage, Image *, const CompositeOperator, const Image *, const ssize_t, const ssize_t);
207
+ DEFINE_GVL_STUB6(CompositeImageChannel, Image *, const ChannelType, const CompositeOperator, const Image *, const ssize_t, const ssize_t);
208
+ DEFINE_GVL_STUB1(CompressImageColormap, Image *);
209
+ DEFINE_GVL_STUB4(ContrastStretchImageChannel, Image *, const ChannelType, const double, const double);
210
+ DEFINE_GVL_STUB4(ConvolveImage, const Image *, const size_t, const double *, ExceptionInfo *);
211
+ DEFINE_GVL_STUB5(ConvolveImageChannel, const Image *, const ChannelType, const size_t, const double *, ExceptionInfo *);
212
+ DEFINE_GVL_STUB2(CycleColormapImage, Image *, const ssize_t);
213
+ DEFINE_GVL_STUB3(DrawAffineImage, Image *, const Image *, const AffineMatrix *);
214
+ DEFINE_GVL_STUB1(EqualizeImage, Image *);
215
+ DEFINE_GVL_STUB2(EqualizeImageChannel, Image *, const ChannelType);
216
+ DEFINE_GVL_STUB5(EvaluateImageChannel, Image *, const ChannelType, const MagickEvaluateOperator, const double, ExceptionInfo *);
217
+ DEFINE_GVL_STUB7(FloodfillPaintImage, Image *, const ChannelType, const DrawInfo *, const MagickPixelPacket *, const ssize_t, const ssize_t, const MagickBooleanType);
218
+ DEFINE_GVL_STUB3(FrameImage, const Image *, const FrameInfo *, ExceptionInfo *);
219
+ DEFINE_GVL_STUB6(FunctionImageChannel, Image *, const ChannelType, const MagickFunction, const size_t, const double *, ExceptionInfo *);
220
+ DEFINE_GVL_STUB4(FxImageChannel, const Image *, const ChannelType, const char *, ExceptionInfo *);
221
+ DEFINE_GVL_STUB3(GammaImageChannel, Image *, const ChannelType, const double);
222
+ DEFINE_GVL_STUB5(GaussianBlurImageChannel, const Image *, const ChannelType, const double, const double, ExceptionInfo *);
223
+ DEFINE_GVL_STUB3(GetImageChannelDepth, const Image *, const ChannelType, ExceptionInfo *);
224
+ DEFINE_GVL_STUB6(GetImageChannelDistortion, Image *, const Image *, const ChannelType, const MetricType, double *, ExceptionInfo *);
225
+ DEFINE_GVL_STUB5(GetImageChannelExtrema, const Image *, const ChannelType, size_t *, size_t *, ExceptionInfo *);
226
+ DEFINE_GVL_STUB5(GetImageChannelMean, const Image *, const ChannelType, double *, double *, ExceptionInfo *);
227
+ DEFINE_GVL_STUB2(GetImageClipMask, const Image *, ExceptionInfo *);
228
+ DEFINE_GVL_STUB3(ImplodeImage, const Image *, const double, ExceptionInfo *);
229
+ DEFINE_GVL_STUB8(ImportImagePixels, Image *, const ssize_t, const ssize_t, const size_t,const size_t,const char *, const StorageType, const void *);
230
+ DEFINE_GVL_STUB5(IsImageSimilar, const Image *, const Image *, ssize_t *, ssize_t *, ExceptionInfo *);
231
+ DEFINE_GVL_STUB2(IsImagesEqual, Image *, const Image *);
232
+ DEFINE_GVL_STUB5(LevelColorsImageChannel, Image *, const ChannelType, const MagickPixelPacket *, const MagickPixelPacket *, const MagickBooleanType);
233
+ DEFINE_GVL_STUB2(LevelImage, Image *, const char *);
234
+ DEFINE_GVL_STUB5(LevelImageChannel, Image *, const ChannelType, const double, const double, const double);
235
+ DEFINE_GVL_STUB5(LevelizeImageChannel, Image *, const ChannelType, const double, const double, const double);
236
+ DEFINE_GVL_STUB3(LinearStretchImage, Image *, const double, const double);
237
+ DEFINE_GVL_STUB2(ModulateImage, Image *, const char *);
238
+ DEFINE_GVL_STUB6(MorphologyImageChannel, const Image *, const ChannelType, const MorphologyMethod, const ssize_t, const KernelInfo *, ExceptionInfo *);
239
+ DEFINE_GVL_STUB2(NegateImage, Image *, const MagickBooleanType);
240
+ DEFINE_GVL_STUB3(NegateImageChannel, Image *, const ChannelType, const MagickBooleanType);
241
+ DEFINE_GVL_STUB1(NormalizeImage, Image *);
242
+ DEFINE_GVL_STUB2(NormalizeImageChannel, Image *, const ChannelType);
243
+ DEFINE_GVL_STUB3(OilPaintImage, const Image *, const double, ExceptionInfo *);
244
+ DEFINE_GVL_STUB5(OpaquePaintImageChannel, Image *, const ChannelType, const MagickPixelPacket *, const MagickPixelPacket *, const MagickBooleanType);
245
+ DEFINE_GVL_STUB3(OrderedPosterizeImage, Image *, const char *, ExceptionInfo *);
246
+ DEFINE_GVL_STUB4(PolaroidImage, const Image *, const DrawInfo *, const double, ExceptionInfo *);
247
+ DEFINE_GVL_STUB3(PosterizeImage, Image *, const size_t, const MagickBooleanType);
248
+ DEFINE_GVL_STUB5(ProfileImage, Image *, const char *, const void *, const size_t, const MagickBooleanType);
249
+ DEFINE_GVL_STUB2(QuantizeImage, const QuantizeInfo *, Image *);
250
+ DEFINE_GVL_STUB3(RaiseImage, Image *, const RectangleInfo *, const MagickBooleanType);
251
+ DEFINE_GVL_STUB4(RandomThresholdImageChannel, Image *, const ChannelType, const char *, ExceptionInfo *);
252
+ DEFINE_GVL_STUB3(RemapImage, const QuantizeInfo *, Image *, const Image *);
253
+ DEFINE_GVL_STUB6(ResampleImage, const Image *, const double, const double, const FilterTypes, const double, ExceptionInfo *);
254
+ DEFINE_GVL_STUB6(ResizeImage, const Image *, const size_t, const size_t, const FilterTypes, const double, ExceptionInfo *);
255
+ DEFINE_GVL_STUB5(SegmentImage, Image *, const ColorspaceType, const MagickBooleanType, const double, const double);
256
+ DEFINE_GVL_STUB6(SelectiveBlurImageChannel, const Image *, const ChannelType, const double, const double, const double, ExceptionInfo *);
257
+ DEFINE_GVL_STUB2(SeparateImageChannel, Image *, const ChannelType);
258
+ DEFINE_GVL_STUB3(SeparateImages, const Image *, const ChannelType, ExceptionInfo *);
259
+ DEFINE_GVL_STUB2(SetImageAlphaChannel, Image *, const AlphaChannelType);
260
+ DEFINE_GVL_STUB1(SetImageBackgroundColor, Image *);
261
+ DEFINE_GVL_STUB3(SetImageChannelDepth, Image *, const ChannelType, const size_t);
262
+ DEFINE_GVL_STUB2(SetImageClipMask, Image *, const Image *);
263
+ DEFINE_GVL_STUB2(SetImageDepth, Image *, const size_t);
264
+ DEFINE_GVL_STUB3(SetImageExtent, Image *, const size_t, const size_t);
265
+ DEFINE_GVL_STUB2(SetImageMask, Image *, const Image *);
266
+ DEFINE_GVL_STUB2(SetImageStorageClass, Image *, const ClassType);
267
+ DEFINE_GVL_STUB5(SharpenImageChannel, const Image *, const ChannelType, const double, const double, ExceptionInfo *);
268
+ DEFINE_GVL_STUB5(SigmoidalContrastImageChannel, Image *, const ChannelType, const MagickBooleanType, const double, const double);
269
+ DEFINE_GVL_STUB1(SignatureImage, Image *);
270
+ DEFINE_GVL_STUB2(SolarizeImage, Image *, const double);
271
+ DEFINE_GVL_STUB6(SparseColorImage, const Image *, const ChannelType, const SparseColorMethod, const size_t, const double *, ExceptionInfo *);
272
+ DEFINE_GVL_STUB3(SpreadImage, const Image *, const double, ExceptionInfo *);
273
+ DEFINE_GVL_STUB3(SwirlImage, const Image *, double, ExceptionInfo *);
274
+ DEFINE_GVL_STUB1(SyncImage, Image *);
275
+ DEFINE_GVL_STUB4(TintImage, const Image *, const char *, const PixelPacket, ExceptionInfo *);
276
+ DEFINE_GVL_STUB2(TransformImageColorspace, Image *, const ColorspaceType);
277
+ DEFINE_GVL_STUB4(TransparentPaintImage, Image *, const MagickPixelPacket *, const Quantum, const MagickBooleanType);
278
+ DEFINE_GVL_STUB5(TransparentPaintImageChroma, Image *, const MagickPixelPacket *, const MagickPixelPacket *, const Quantum, const MagickBooleanType);
279
+ DEFINE_GVL_STUB7(UnsharpMaskImageChannel, const Image *, const ChannelType, const double, const double, const double, const double, ExceptionInfo *);
280
+ DEFINE_GVL_STUB4(WaveImage, const Image *, const double, const double, ExceptionInfo *);
281
+ DEFINE_GVL_STUB2(WhiteThresholdImage, Image *, const char *);
282
+ DEFINE_GVL_STUB2(WriteImage, const ImageInfo *, Image *);
283
+ #endif
284
+
285
+ #if defined(HAVE_GETIMAGECHANNELENTROPY)
286
+ DEFINE_GVL_STUB4(GetImageChannelEntropy, const Image *, const ChannelType, double *, ExceptionInfo *);
287
+ #endif
288
+
289
+ #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
290
+ DEFINE_GVL_STUB3(RotationalBlurImage, const Image *, const double, ExceptionInfo *);
291
+ #else
292
+ DEFINE_GVL_STUB3(RadialBlurImage, const Image *, const double, ExceptionInfo *);
293
+ #endif
294
+
295
+ #if defined(IMAGEMAGICK_7)
296
+ #elif defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
297
+ DEFINE_GVL_STUB4(RotationalBlurImageChannel, const Image *, const ChannelType, const double, ExceptionInfo *);
298
+ #else
299
+ DEFINE_GVL_STUB4(RadialBlurImageChannel, const Image *, const ChannelType, const double, ExceptionInfo *);
300
+ #endif
301
+
73
302
  /**
74
303
  * Returns the alpha value from the hash.
75
304
  *
@@ -100,6 +329,9 @@ get_named_alpha_value(VALUE hash)
100
329
  }
101
330
 
102
331
 
332
+ // aliases for common use of structure types; AdaptiveBlurImage, AdaptiveSharpenImage
333
+ typedef GVL_STRUCT_TYPE(AdaptiveBlurImage) GVL_STRUCT_TYPE(adaptive_method);
334
+
103
335
  /**
104
336
  * Call Adaptive(Blur|Sharpen)Image.
105
337
  *
@@ -112,8 +344,7 @@ get_named_alpha_value(VALUE hash)
112
344
  * @return a new image
113
345
  */
114
346
  static VALUE
115
- adaptive_method(int argc, VALUE *argv, VALUE self,
116
- Image *fp(const Image *, const double, const double, ExceptionInfo *))
347
+ adaptive_method(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
117
348
  {
118
349
  Image *image, *new_image;
119
350
  double radius = 0.0;
@@ -137,7 +368,8 @@ adaptive_method(int argc, VALUE *argv, VALUE self,
137
368
 
138
369
  exception = AcquireExceptionInfo();
139
370
 
140
- new_image = (fp)(image, radius, sigma, exception);
371
+ GVL_STRUCT_TYPE(adaptive_method) args = { image, radius, sigma, exception };
372
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
141
373
  rm_check_exception(exception, new_image, DestroyOnError);
142
374
  DestroyExceptionInfo(exception);
143
375
 
@@ -145,6 +377,12 @@ adaptive_method(int argc, VALUE *argv, VALUE self,
145
377
  }
146
378
 
147
379
 
380
+ // aliases for common use of structure types; AdaptiveBlurImage, AdaptiveSharpenImage, AdaptiveBlurImageChannel, AdaptiveSharpenImageChannel
381
+ #if defined(IMAGEMAGICK_7)
382
+ typedef GVL_STRUCT_TYPE(AdaptiveBlurImage) GVL_STRUCT_TYPE(adaptive_channel_method);
383
+ #else
384
+ typedef GVL_STRUCT_TYPE(AdaptiveBlurImageChannel) GVL_STRUCT_TYPE(adaptive_channel_method);
385
+ #endif
148
386
 
149
387
  /**
150
388
  * Call Adaptive(Blur|Sharpen)ImageChannel.
@@ -158,7 +396,7 @@ adaptive_method(int argc, VALUE *argv, VALUE self,
158
396
  * @return a new image
159
397
  */
160
398
  static VALUE
161
- adaptive_channel_method(int argc, VALUE *argv, VALUE self, channel_method_t fp)
399
+ adaptive_channel_method(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
162
400
  {
163
401
  Image *image, *new_image;
164
402
  double radius = 0.0;
@@ -186,11 +424,13 @@ adaptive_channel_method(int argc, VALUE *argv, VALUE self, channel_method_t fp)
186
424
 
187
425
  #if defined(IMAGEMAGICK_7)
188
426
  BEGIN_CHANNEL_MASK(image, channels);
189
- new_image = (fp)(image, radius, sigma, exception);
427
+ GVL_STRUCT_TYPE(adaptive_channel_method) args = { image, radius, sigma, exception };
428
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
190
429
  CHANGE_RESULT_CHANNEL_MASK(new_image);
191
430
  END_CHANNEL_MASK(image);
192
431
  #else
193
- new_image = (fp)(image, channels, radius, sigma, exception);
432
+ GVL_STRUCT_TYPE(adaptive_channel_method) args = { image, channels, radius, sigma, exception };
433
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
194
434
  #endif
195
435
 
196
436
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -214,11 +454,10 @@ adaptive_channel_method(int argc, VALUE *argv, VALUE self, channel_method_t fp)
214
454
  VALUE
215
455
  Image_adaptive_blur(int argc, VALUE *argv, VALUE self)
216
456
  {
217
- return adaptive_method(argc, argv, self, AdaptiveBlurImage);
457
+ return adaptive_method(argc, argv, self, GVL_FUNC(AdaptiveBlurImage));
218
458
  }
219
459
 
220
460
 
221
-
222
461
  /**
223
462
  * The same as {Magick::Image#adaptive_blur} except only the specified channels are blurred.
224
463
  *
@@ -238,9 +477,9 @@ VALUE
238
477
  Image_adaptive_blur_channel(int argc, VALUE *argv, VALUE self)
239
478
  {
240
479
  #if defined(IMAGEMAGICK_7)
241
- return adaptive_channel_method(argc, argv, self, AdaptiveBlurImage);
480
+ return adaptive_channel_method(argc, argv, self, GVL_FUNC(AdaptiveBlurImage));
242
481
  #else
243
- return adaptive_channel_method(argc, argv, self, AdaptiveBlurImageChannel);
482
+ return adaptive_channel_method(argc, argv, self, GVL_FUNC(AdaptiveBlurImageChannel));
244
483
  #endif
245
484
  }
246
485
 
@@ -296,7 +535,8 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
296
535
  }
297
536
 
298
537
  exception = AcquireExceptionInfo();
299
- new_image = AdaptiveResizeImage(image, columns, rows, exception);
538
+ GVL_STRUCT_TYPE(AdaptiveResizeImage) args = { image, columns, rows, exception };
539
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AdaptiveResizeImage), &args);
300
540
  rm_check_exception(exception, new_image, DestroyOnError);
301
541
  DestroyExceptionInfo(exception);
302
542
 
@@ -304,7 +544,6 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
304
544
  }
305
545
 
306
546
 
307
-
308
547
  /**
309
548
  * Adaptively sharpens the image by sharpening more intensely near image edges and less intensely
310
549
  * far from edges.
@@ -323,11 +562,10 @@ Image_adaptive_resize(int argc, VALUE *argv, VALUE self)
323
562
  VALUE
324
563
  Image_adaptive_sharpen(int argc, VALUE *argv, VALUE self)
325
564
  {
326
- return adaptive_method(argc, argv, self, AdaptiveSharpenImage);
565
+ return adaptive_method(argc, argv, self, GVL_FUNC(AdaptiveSharpenImage));
327
566
  }
328
567
 
329
568
 
330
-
331
569
  /**
332
570
  * The same as {Magick::Image#adaptive_sharpen} except only the specified channels are sharpened.
333
571
  *
@@ -347,14 +585,13 @@ VALUE
347
585
  Image_adaptive_sharpen_channel(int argc, VALUE *argv, VALUE self)
348
586
  {
349
587
  #if defined(IMAGEMAGICK_7)
350
- return adaptive_channel_method(argc, argv, self, AdaptiveSharpenImage);
588
+ return adaptive_channel_method(argc, argv, self, GVL_FUNC(AdaptiveSharpenImage));
351
589
  #else
352
- return adaptive_channel_method(argc, argv, self, AdaptiveSharpenImageChannel);
590
+ return adaptive_channel_method(argc, argv, self, GVL_FUNC(AdaptiveSharpenImageChannel));
353
591
  #endif
354
592
  }
355
593
 
356
594
 
357
-
358
595
  /**
359
596
  * Selects an individual threshold for each pixel based on the range of intensity values in its
360
597
  * local neighborhood. This allows for thresholding of an image whose global intensity histogram
@@ -391,7 +628,8 @@ Image_adaptive_threshold(int argc, VALUE *argv, VALUE self)
391
628
  }
392
629
 
393
630
  exception = AcquireExceptionInfo();
394
- new_image = AdaptiveThresholdImage(image, width, height, offset, exception);
631
+ GVL_STRUCT_TYPE(AdaptiveThresholdImage) args = { image, width, height, offset, exception };
632
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AdaptiveThresholdImage), &args);
395
633
  rm_check_exception(exception, new_image, DestroyOnError);
396
634
  DestroyExceptionInfo(exception);
397
635
 
@@ -430,17 +668,21 @@ Image_add_compose_mask(VALUE self, VALUE mask)
430
668
  clip_mask = rm_clone_image(mask_image);
431
669
 
432
670
  exception = AcquireExceptionInfo();
433
- NegateImage(clip_mask, MagickFalse, exception);
671
+ GVL_STRUCT_TYPE(NegateImage) args_NegateImage = { clip_mask, MagickFalse, exception };
672
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args_NegateImage);
434
673
  rm_check_exception(exception, clip_mask, DestroyOnError);
435
- SetImageMask(image, CompositePixelMask, clip_mask, exception);
674
+ GVL_STRUCT_TYPE(SetImageMask) args_SetImageMask = { image, CompositePixelMask, clip_mask, exception };
675
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args_SetImageMask);
436
676
  DestroyImage(clip_mask);
437
677
  CHECK_EXCEPTION();
438
678
  DestroyExceptionInfo(exception);
439
679
  #else
440
680
  // Delete any previously-existing mask image.
441
681
  // Store a clone of the new mask image.
442
- SetImageMask(image, mask_image);
443
- NegateImage(image->mask, MagickFalse);
682
+ GVL_STRUCT_TYPE(SetImageMask) args_SetImageMask = { image, mask_image };
683
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args_SetImageMask);
684
+ GVL_STRUCT_TYPE(NegateImage) args_NegateImage = { image->mask, MagickFalse };
685
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args_NegateImage);
444
686
 
445
687
  // Since both Set and GetImageMask clone the mask image I don't see any
446
688
  // way to negate the mask without referencing it directly. Sigh.
@@ -469,10 +711,11 @@ Image_add_noise(VALUE self, VALUE noise)
469
711
 
470
712
  exception = AcquireExceptionInfo();
471
713
  #if defined(IMAGEMAGICK_7)
472
- new_image = AddNoiseImage(image, noise_type, 1.0, exception);
714
+ GVL_STRUCT_TYPE(AddNoiseImage) args = { image, noise_type, 1.0, exception };
473
715
  #else
474
- new_image = AddNoiseImage(image, noise_type, exception);
716
+ GVL_STRUCT_TYPE(AddNoiseImage) args = { image, noise_type, exception };
475
717
  #endif
718
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AddNoiseImage), &args);
476
719
  rm_check_exception(exception, new_image, DestroyOnError);
477
720
  DestroyExceptionInfo(exception);
478
721
 
@@ -519,10 +762,12 @@ Image_add_noise_channel(int argc, VALUE *argv, VALUE self)
519
762
  exception = AcquireExceptionInfo();
520
763
  #if defined(IMAGEMAGICK_7)
521
764
  BEGIN_CHANNEL_MASK(image, channels);
522
- new_image = AddNoiseImage(image, noise_type, 1.0, exception);
765
+ GVL_STRUCT_TYPE(AddNoiseImage) args = { image, noise_type, 1.0, exception };
766
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AddNoiseImage), &args);
523
767
  END_CHANNEL_MASK(new_image);
524
768
  #else
525
- new_image = AddNoiseImageChannel(image, channels, noise_type, exception);
769
+ GVL_STRUCT_TYPE(AddNoiseImageChannel) args = { image, channels, noise_type, exception };
770
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AddNoiseImageChannel), &args);
526
771
  #endif
527
772
  rm_check_exception(exception, new_image, DestroyOnError);
528
773
  DestroyExceptionInfo(exception);
@@ -580,10 +825,12 @@ Image_add_profile(VALUE self, VALUE name)
580
825
  if (profile)
581
826
  {
582
827
  #if defined(IMAGEMAGICK_7)
583
- ProfileImage(image, profile_name, GetStringInfoDatum(profile), GetStringInfoLength(profile), exception);
828
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, profile_name, GetStringInfoDatum(profile), GetStringInfoLength(profile), exception };
829
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
584
830
  if (rm_should_raise_exception(exception, RetainExceptionRetention))
585
831
  #else
586
- ProfileImage(image, profile_name, GetStringInfoDatum(profile), GetStringInfoLength(profile), MagickFalse);
832
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, profile_name, GetStringInfoDatum(profile), GetStringInfoLength(profile), MagickFalse };
833
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
587
834
  if (rm_should_raise_exception(&image->exception, RetainExceptionRetention))
588
835
  #endif
589
836
  {
@@ -654,11 +901,13 @@ Image_alpha(int argc, VALUE *argv, VALUE self)
654
901
 
655
902
  #if defined(IMAGEMAGICK_7)
656
903
  exception = AcquireExceptionInfo();
657
- SetImageAlphaChannel(image, alpha, exception);
904
+ GVL_STRUCT_TYPE(SetImageAlphaChannel) args = { image, alpha, exception };
905
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageAlphaChannel), &args);
658
906
  CHECK_EXCEPTION();
659
907
  DestroyExceptionInfo(exception);
660
908
  #else
661
- SetImageAlphaChannel(image, alpha);
909
+ GVL_STRUCT_TYPE(SetImageAlphaChannel) args = { image, alpha };
910
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageAlphaChannel), &args);
662
911
  rm_check_image_exception(image, RetainOnError);
663
912
  #endif
664
913
 
@@ -703,7 +952,8 @@ Image_affine_transform(VALUE self, VALUE affine)
703
952
  Export_AffineMatrix(&matrix, affine);
704
953
 
705
954
  exception = AcquireExceptionInfo();
706
- new_image = AffineTransformImage(image, &matrix, exception);
955
+ GVL_STRUCT_TYPE(AffineTransformImage) args = { image, &matrix, exception };
956
+ new_image = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(AffineTransformImage), &args);
707
957
  rm_check_exception(exception, new_image, DestroyOnError);
708
958
  DestroyExceptionInfo(exception);
709
959
 
@@ -825,6 +1075,9 @@ Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg)
825
1075
  }
826
1076
 
827
1077
 
1078
+ // aliases for common use of structure types; TransposeImage, TransverseImage
1079
+ typedef GVL_STRUCT_TYPE(TransposeImage) GVL_STRUCT_TYPE(crisscross);
1080
+
828
1081
  /**
829
1082
  * Handle #transverse, #transform methods.
830
1083
  *
@@ -836,15 +1089,16 @@ Image_aset(VALUE self, VALUE key_arg, VALUE attr_arg)
836
1089
  * @return self if bang, otherwise a new image
837
1090
  */
838
1091
  static VALUE
839
- crisscross(int bang, VALUE self, Image *fp(const Image *, ExceptionInfo *))
1092
+ crisscross(int bang, VALUE self, gvl_function_t fp)
840
1093
  {
841
1094
  Image *image, *new_image;
842
1095
  ExceptionInfo *exception;
843
1096
 
844
- Data_Get_Struct(self, Image, image);
1097
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
845
1098
  exception = AcquireExceptionInfo();
846
1099
 
847
- new_image = (fp)(image, exception);
1100
+ GVL_STRUCT_TYPE(crisscross) args = { image, exception };
1101
+ new_image = CALL_FUNC_WITHOUT_GVL(fp, &args);
848
1102
  rm_check_exception(exception, new_image, DestroyOnError);
849
1103
  DestroyExceptionInfo(exception);
850
1104
 
@@ -861,6 +1115,12 @@ crisscross(int bang, VALUE self, Image *fp(const Image *, ExceptionInfo *))
861
1115
  }
862
1116
 
863
1117
 
1118
+ // aliases for common use of structure types; AutoGammaImage, AutoLevelImage, AutoGammaImageChannel, AutoLevelImageChannel
1119
+ #if defined(IMAGEMAGICK_7)
1120
+ typedef GVL_STRUCT_TYPE(AutoGammaImage) GVL_STRUCT_TYPE(auto_channel);
1121
+ #else
1122
+ typedef GVL_STRUCT_TYPE(AutoGammaImageChannel) GVL_STRUCT_TYPE(auto_channel);
1123
+ #endif
864
1124
 
865
1125
  /**
866
1126
  * Handle #auto_gamma_channel, #auto_level_channel methods.
@@ -874,7 +1134,7 @@ crisscross(int bang, VALUE self, Image *fp(const Image *, ExceptionInfo *))
874
1134
  * @return a new image
875
1135
  */
876
1136
  static VALUE
877
- auto_channel(int argc, VALUE *argv, VALUE self, auto_channel_t fp)
1137
+ auto_channel(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
878
1138
  {
879
1139
  Image *image, *new_image;
880
1140
  ChannelType channels;
@@ -895,12 +1155,14 @@ auto_channel(int argc, VALUE *argv, VALUE self, auto_channel_t fp)
895
1155
  #if defined(IMAGEMAGICK_7)
896
1156
  exception = AcquireExceptionInfo();
897
1157
  BEGIN_CHANNEL_MASK(new_image, channels);
898
- (fp)(new_image, exception);
1158
+ GVL_STRUCT_TYPE(auto_channel) args = { new_image, exception };
1159
+ CALL_FUNC_WITHOUT_GVL(fp, &args);
899
1160
  END_CHANNEL_MASK(new_image);
900
1161
  rm_check_exception(exception, new_image, DestroyOnError);
901
1162
  DestroyExceptionInfo(exception);
902
1163
  #else
903
- (fp)(new_image, channels);
1164
+ GVL_STRUCT_TYPE(auto_channel) args = { new_image, channels };
1165
+ CALL_FUNC_WITHOUT_GVL(fp, &args);
904
1166
  rm_check_image_exception(new_image, DestroyOnError);
905
1167
  #endif
906
1168
 
@@ -923,9 +1185,9 @@ VALUE
923
1185
  Image_auto_gamma_channel(int argc, VALUE *argv, VALUE self)
924
1186
  {
925
1187
  #if defined(IMAGEMAGICK_7)
926
- return auto_channel(argc, argv, self, AutoGammaImage);
1188
+ return auto_channel(argc, argv, self, GVL_FUNC(AutoGammaImage));
927
1189
  #else
928
- return auto_channel(argc, argv, self, AutoGammaImageChannel);
1190
+ return auto_channel(argc, argv, self, GVL_FUNC(AutoGammaImageChannel));
929
1191
  #endif
930
1192
  }
931
1193
 
@@ -945,9 +1207,9 @@ VALUE
945
1207
  Image_auto_level_channel(int argc, VALUE *argv, VALUE self)
946
1208
  {
947
1209
  #if defined(IMAGEMAGICK_7)
948
- return auto_channel(argc, argv, self, AutoLevelImage);
1210
+ return auto_channel(argc, argv, self, GVL_FUNC(AutoLevelImage));
949
1211
  #else
950
- return auto_channel(argc, argv, self, AutoLevelImageChannel);
1212
+ return auto_channel(argc, argv, self, GVL_FUNC(AutoLevelImageChannel));
951
1213
  #endif
952
1214
  }
953
1215
 
@@ -970,12 +1232,12 @@ auto_orient(int bang, VALUE self)
970
1232
  VALUE new_image;
971
1233
  VALUE degrees[1];
972
1234
 
973
- Data_Get_Struct(self, Image, image);
1235
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
974
1236
 
975
1237
  switch (image->orientation)
976
1238
  {
977
1239
  case TopRightOrientation:
978
- new_image = flipflop(bang, self, FlopImage);
1240
+ new_image = flipflop(bang, self, GVL_FUNC(FlopImage));
979
1241
  break;
980
1242
 
981
1243
  case BottomRightOrientation:
@@ -984,11 +1246,11 @@ auto_orient(int bang, VALUE self)
984
1246
  break;
985
1247
 
986
1248
  case BottomLeftOrientation:
987
- new_image = flipflop(bang, self, FlipImage);
1249
+ new_image = flipflop(bang, self, GVL_FUNC(FlipImage));
988
1250
  break;
989
1251
 
990
1252
  case LeftTopOrientation:
991
- new_image = crisscross(bang, self, TransposeImage);
1253
+ new_image = crisscross(bang, self, GVL_FUNC(TransposeImage));
992
1254
  break;
993
1255
 
994
1256
  case RightTopOrientation:
@@ -997,7 +1259,7 @@ auto_orient(int bang, VALUE self)
997
1259
  break;
998
1260
 
999
1261
  case RightBottomOrientation:
1000
- new_image = crisscross(bang, self, TransverseImage);
1262
+ new_image = crisscross(bang, self, GVL_FUNC(TransverseImage));
1001
1263
  break;
1002
1264
 
1003
1265
  case LeftBottomOrientation:
@@ -1011,7 +1273,7 @@ auto_orient(int bang, VALUE self)
1011
1273
  }
1012
1274
 
1013
1275
 
1014
- Data_Get_Struct(new_image, Image, image);
1276
+ TypedData_Get_Struct(new_image, Image, &rm_image_data_type, image);
1015
1277
  image->orientation = TopLeftOrientation;
1016
1278
 
1017
1279
  RB_GC_GUARD(new_image);
@@ -1230,12 +1492,14 @@ Image_bilevel_channel(int argc, VALUE *argv, VALUE self)
1230
1492
  #if defined(IMAGEMAGICK_7)
1231
1493
  exception = AcquireExceptionInfo();
1232
1494
  BEGIN_CHANNEL_MASK(new_image, channels);
1233
- BilevelImage(new_image, threshold, exception);
1495
+ GVL_STRUCT_TYPE(BilevelImage) args = { new_image, threshold, exception };
1496
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BilevelImage), &args);
1234
1497
  END_CHANNEL_MASK(new_image);
1235
1498
  rm_check_exception(exception, new_image, DestroyOnError);
1236
1499
  DestroyExceptionInfo(exception);
1237
1500
  #else
1238
- BilevelImageChannel(new_image, channels, threshold);
1501
+ GVL_STRUCT_TYPE(BilevelImageChannel) args = { new_image, channels, threshold };
1502
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BilevelImageChannel), &args);
1239
1503
  rm_check_image_exception(new_image, DestroyOnError);
1240
1504
  #endif
1241
1505
 
@@ -1322,7 +1586,7 @@ Image_black_point_compensation_eq(VALUE self, VALUE arg)
1322
1586
  VALUE
1323
1587
  Image_black_threshold(int argc, VALUE *argv, VALUE self)
1324
1588
  {
1325
- return threshold_image(argc, argv, self, BlackThresholdImage);
1589
+ return threshold_image(argc, argv, self, GVL_FUNC(BlackThresholdImage));
1326
1590
  }
1327
1591
 
1328
1592
 
@@ -1632,11 +1896,13 @@ special_composite(Image *image, Image *overlay, double image_pct, double overlay
1632
1896
 
1633
1897
  #if defined(IMAGEMAGICK_7)
1634
1898
  exception = AcquireExceptionInfo();
1635
- CompositeImage(new_image, overlay, op, MagickTrue, x_off, y_off, exception);
1899
+ GVL_STRUCT_TYPE(CompositeImage) args = { new_image, overlay, op, MagickTrue, x_off, y_off, exception };
1900
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
1636
1901
  rm_check_exception(exception, new_image, DestroyOnError);
1637
1902
  DestroyExceptionInfo(exception);
1638
1903
  #else
1639
- CompositeImage(new_image, op, overlay, x_off, y_off);
1904
+ GVL_STRUCT_TYPE(CompositeImage) args = { new_image, op, overlay, x_off, y_off };
1905
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
1640
1906
 
1641
1907
  rm_check_image_exception(new_image, DestroyOnError);
1642
1908
  #endif
@@ -1743,7 +2009,8 @@ Image_blue_shift(int argc, VALUE *argv, VALUE self)
1743
2009
 
1744
2010
 
1745
2011
  exception = AcquireExceptionInfo();
1746
- new_image = BlueShiftImage(image, factor, exception);
2012
+ GVL_STRUCT_TYPE(BlueShiftImage) args = { image, factor, exception };
2013
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlueShiftImage), &args);
1747
2014
  CHECK_EXCEPTION();
1748
2015
  DestroyExceptionInfo(exception);
1749
2016
 
@@ -1795,11 +2062,13 @@ Image_blur_channel(int argc, VALUE *argv, VALUE self)
1795
2062
  exception = AcquireExceptionInfo();
1796
2063
  #if defined(IMAGEMAGICK_7)
1797
2064
  BEGIN_CHANNEL_MASK(image, channels);
1798
- new_image = BlurImage(image, radius, sigma, exception);
2065
+ GVL_STRUCT_TYPE(BlurImage) args = { image, radius, sigma, exception };
2066
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlurImage), &args);
1799
2067
  CHANGE_RESULT_CHANNEL_MASK(new_image);
1800
2068
  END_CHANNEL_MASK(image);
1801
2069
  #else
1802
- new_image = BlurImageChannel(image, channels, radius, sigma, exception);
2070
+ GVL_STRUCT_TYPE(BlurImageChannel) args = { image, channels, radius, sigma, exception };
2071
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlurImageChannel), &args);
1803
2072
  #endif
1804
2073
  rm_check_exception(exception, new_image, DestroyOnError);
1805
2074
  DestroyExceptionInfo(exception);
@@ -1819,7 +2088,7 @@ Image_blur_channel(int argc, VALUE *argv, VALUE self)
1819
2088
  VALUE
1820
2089
  Image_blur_image(int argc, VALUE *argv, VALUE self)
1821
2090
  {
1822
- return effect_image(self, argc, argv, BlurImage);
2091
+ return effect_image(self, argc, argv, GVL_FUNC(BlurImage));
1823
2092
  }
1824
2093
 
1825
2094
 
@@ -1846,7 +2115,7 @@ border(int bang, VALUE self, VALUE width, VALUE height, VALUE color)
1846
2115
  ExceptionInfo *exception;
1847
2116
  RectangleInfo rect;
1848
2117
 
1849
- Data_Get_Struct(self, Image, image);
2118
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
1850
2119
 
1851
2120
  memset(&rect, 0, sizeof(rect));
1852
2121
  rect.width = NUM2UINT(width);
@@ -1858,10 +2127,11 @@ border(int bang, VALUE self, VALUE width, VALUE height, VALUE color)
1858
2127
 
1859
2128
  exception = AcquireExceptionInfo();
1860
2129
  #if defined(IMAGEMAGICK_7)
1861
- new_image = BorderImage(image, &rect, image->compose, exception);
2130
+ GVL_STRUCT_TYPE(BorderImage) args = { image, &rect, image->compose, exception };
1862
2131
  #else
1863
- new_image = BorderImage(image, &rect, exception);
2132
+ GVL_STRUCT_TYPE(BorderImage) args = { image, &rect, exception };
1864
2133
  #endif
2134
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BorderImage), &args);
1865
2135
  rm_check_exception(exception, new_image, DestroyOnError);
1866
2136
  DestroyExceptionInfo(exception);
1867
2137
 
@@ -1990,12 +2260,12 @@ Image_bounding_box(VALUE self)
1990
2260
  * importantly, you can capture menus or other popups that are independent windows but appear
1991
2261
  * over the specified window.
1992
2262
  * @param borders [Boolean] If true, include the border in the image.
1993
- * @yield []
2263
+ * @yield [Magick::Image::Info]
1994
2264
  *
1995
2265
  * @return [Magick::Image] a new image
1996
2266
  * @example
1997
- * img = Image.capture {
1998
- * self.filename = "root"
2267
+ * img = Image.capture { |options|
2268
+ * options.filename = "root"
1999
2269
  * }
2000
2270
  */
2001
2271
  VALUE
@@ -2035,7 +2305,7 @@ Image_capture(int argc, VALUE *argv, VALUE self ATTRIBUTE_UNUSED)
2035
2305
  // Set info->server_name to the server name
2036
2306
  // Also info->colorspace, depth, dither, interlace, type
2037
2307
  info_obj = rm_info_new();
2038
- Data_Get_Struct(info_obj, Info, image_info);
2308
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, image_info);
2039
2309
 
2040
2310
  // If an error occurs, IM will call our error handler and we raise an exception.
2041
2311
  #if defined(IMAGEMAGICK_7)
@@ -2146,12 +2416,14 @@ Image_channel(VALUE self, VALUE channel_arg)
2146
2416
 
2147
2417
  #if defined(IMAGEMAGICK_7)
2148
2418
  exception = AcquireExceptionInfo();
2149
- new_image = SeparateImage(image, channel, exception);
2419
+ GVL_STRUCT_TYPE(SeparateImage) args = { image, channel, exception };
2420
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SeparateImage), &args);
2150
2421
  rm_check_exception(exception, new_image, DestroyOnError);
2151
2422
  DestroyExceptionInfo(exception);
2152
2423
  #else
2153
2424
  new_image = rm_clone_image(image);
2154
- SeparateImageChannel(new_image, channel);
2425
+ GVL_STRUCT_TYPE(SeparateImageChannel) args = { new_image, channel };
2426
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SeparateImageChannel), &args);
2155
2427
 
2156
2428
  rm_check_image_exception(new_image, DestroyOnError);
2157
2429
  #endif
@@ -2176,7 +2448,7 @@ Image_channel_depth(int argc, VALUE *argv, VALUE self)
2176
2448
  {
2177
2449
  Image *image;
2178
2450
  ChannelType channels;
2179
- unsigned long channel_depth;
2451
+ size_t channel_depth;
2180
2452
  ExceptionInfo *exception;
2181
2453
 
2182
2454
  image = rm_check_destroyed(self);
@@ -2192,10 +2464,12 @@ Image_channel_depth(int argc, VALUE *argv, VALUE self)
2192
2464
 
2193
2465
  #if defined(IMAGEMAGICK_7)
2194
2466
  BEGIN_CHANNEL_MASK(image, channels);
2195
- channel_depth = GetImageDepth(image, exception);
2467
+ GVL_STRUCT_TYPE(GetImageDepth) args = { image, exception };
2468
+ channel_depth = (size_t)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageDepth), &args);
2196
2469
  END_CHANNEL_MASK(image);
2197
2470
  #else
2198
- channel_depth = GetImageChannelDepth(image, channels, exception);
2471
+ GVL_STRUCT_TYPE(GetImageChannelDepth) args = { image, channels, exception };
2472
+ channel_depth = (size_t)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelDepth), &args);
2199
2473
  #endif
2200
2474
  CHECK_EXCEPTION();
2201
2475
 
@@ -2239,10 +2513,12 @@ Image_channel_extrema(int argc, VALUE *argv, VALUE self)
2239
2513
  exception = AcquireExceptionInfo();
2240
2514
  #if defined(IMAGEMAGICK_7)
2241
2515
  BEGIN_CHANNEL_MASK(image, channels);
2242
- GetImageExtrema(image, &min, &max, exception);
2516
+ GVL_STRUCT_TYPE(GetImageExtrema) args = { image, &min, &max, exception };
2517
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageExtrema), &args);
2243
2518
  END_CHANNEL_MASK(image);
2244
2519
  #else
2245
- GetImageChannelExtrema(image, channels, &min, &max, exception);
2520
+ GVL_STRUCT_TYPE(GetImageChannelExtrema) args = { image, channels, &min, &max, exception };
2521
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelExtrema), &args);
2246
2522
  #endif
2247
2523
  CHECK_EXCEPTION();
2248
2524
 
@@ -2292,10 +2568,12 @@ Image_channel_mean(int argc, VALUE *argv, VALUE self)
2292
2568
  exception = AcquireExceptionInfo();
2293
2569
  #if defined(IMAGEMAGICK_7)
2294
2570
  BEGIN_CHANNEL_MASK(image, channels);
2295
- GetImageMean(image, &mean, &stddev, exception);
2571
+ GVL_STRUCT_TYPE(GetImageMean) args = { image, &mean, &stddev, exception };
2572
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageMean), &args);
2296
2573
  END_CHANNEL_MASK(image);
2297
2574
  #else
2298
- GetImageChannelMean(image, channels, &mean, &stddev, exception);
2575
+ GVL_STRUCT_TYPE(GetImageChannelMean) args = { image, channels, &mean, &stddev, exception };
2576
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelMean), &args);
2299
2577
  #endif
2300
2578
  CHECK_EXCEPTION();
2301
2579
 
@@ -2344,10 +2622,12 @@ Image_channel_entropy(int argc, VALUE *argv, VALUE self)
2344
2622
  exception = AcquireExceptionInfo();
2345
2623
  #if defined(IMAGEMAGICK_7)
2346
2624
  BEGIN_CHANNEL_MASK(image, channels);
2347
- GetImageEntropy(image, &entropy, exception);
2625
+ GVL_STRUCT_TYPE(GetImageEntropy) args = { image, &entropy, exception };
2626
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageEntropy), &args);
2348
2627
  END_CHANNEL_MASK(image);
2349
2628
  #else
2350
- GetImageChannelEntropy(image, channels, &entropy, exception);
2629
+ GVL_STRUCT_TYPE(GetImageChannelEntropy) args = { image, channels, &entropy, exception };
2630
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelEntropy), &args);
2351
2631
  #endif
2352
2632
  CHECK_EXCEPTION();
2353
2633
 
@@ -2379,7 +2659,7 @@ Image_channel_entropy(int argc ATTRIBUTE_UNUSED, VALUE *argv ATTRIBUTE_UNUSED, V
2379
2659
  VALUE
2380
2660
  Image_charcoal(int argc, VALUE *argv, VALUE self)
2381
2661
  {
2382
- return effect_image(self, argc, argv, CharcoalImage);
2662
+ return effect_image(self, argc, argv, GVL_FUNC(CharcoalImage));
2383
2663
  }
2384
2664
 
2385
2665
 
@@ -2410,7 +2690,7 @@ VALUE
2410
2690
  Image_chop(VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
2411
2691
  {
2412
2692
  rm_check_destroyed(self);
2413
- return xform_image(False, self, x, y, width, height, ChopImage);
2693
+ return xform_image(False, self, x, y, width, height, GVL_FUNC(ChopImage));
2414
2694
  }
2415
2695
 
2416
2696
 
@@ -2515,17 +2795,19 @@ Image_clut_channel(int argc, VALUE *argv, VALUE self)
2515
2795
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 1 or more)", argc);
2516
2796
  }
2517
2797
 
2518
- Data_Get_Struct(argv[0], Image, clut);
2798
+ TypedData_Get_Struct(argv[0], Image, &rm_image_data_type, clut);
2519
2799
 
2520
2800
  #if defined(IMAGEMAGICK_7)
2521
2801
  exception = AcquireExceptionInfo();
2522
2802
  BEGIN_CHANNEL_MASK(image, channels);
2523
- okay = ClutImage(image, clut, image->interpolate, exception);
2803
+ GVL_STRUCT_TYPE(ClutImage) args = { image, clut, image->interpolate, exception };
2804
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImage), &args);
2524
2805
  END_CHANNEL_MASK(image);
2525
2806
  CHECK_EXCEPTION();
2526
2807
  DestroyExceptionInfo(exception);
2527
2808
  #else
2528
- okay = ClutImageChannel(image, channels, clut);
2809
+ GVL_STRUCT_TYPE(ClutImageChannel) args = { image, channels, clut };
2810
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ClutImageChannel), &args);
2529
2811
  rm_check_image_exception(image, RetainOnError);
2530
2812
  rm_check_image_exception(clut, RetainOnError);
2531
2813
  #endif
@@ -2566,14 +2848,16 @@ Image_color_histogram(VALUE self)
2566
2848
  {
2567
2849
  dc_copy = rm_clone_image(image);
2568
2850
  #if defined(IMAGEMAGICK_7)
2569
- SetImageStorageClass(dc_copy, DirectClass, exception);
2851
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { dc_copy, DirectClass, exception };
2570
2852
  #else
2571
- SetImageStorageClass(dc_copy, DirectClass);
2853
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { dc_copy, DirectClass };
2572
2854
  #endif
2855
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
2573
2856
  image = dc_copy;
2574
2857
  }
2575
2858
 
2576
- histogram = GetImageHistogram(image, &colors, exception);
2859
+ GVL_STRUCT_TYPE(GetImageHistogram) args = { image, &colors, exception };
2860
+ histogram = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageHistogram), &args);
2577
2861
 
2578
2862
  if (histogram == NULL)
2579
2863
  {
@@ -2667,7 +2951,8 @@ set_profile(VALUE self, const char *name, VALUE profile)
2667
2951
 
2668
2952
  strlcpy(info->magick, m->name, sizeof(info->magick));
2669
2953
 
2670
- profile_image = BlobToImage(info, profile_blob, (size_t)profile_length, exception);
2954
+ GVL_STRUCT_TYPE(BlobToImage) args = { info, profile_blob, (size_t)profile_length, exception };
2955
+ profile_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
2671
2956
  DestroyImageInfo(info);
2672
2957
  CHECK_EXCEPTION();
2673
2958
 
@@ -2679,10 +2964,12 @@ set_profile(VALUE self, const char *name, VALUE profile)
2679
2964
  if (rm_strcasecmp("8bim", profile_name) == 0 && rm_strcasecmp("iptc", name) == 0)
2680
2965
  {
2681
2966
  #if defined(IMAGEMAGICK_7)
2682
- ProfileImage(image, name, profile_blob, profile_length, exception);
2967
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, name, profile_blob, profile_length, exception };
2968
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
2683
2969
  if (rm_should_raise_exception(exception, RetainExceptionRetention))
2684
2970
  #else
2685
- ProfileImage(image, name, profile_blob, profile_length, MagickFalse);
2971
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, name, profile_blob, profile_length, MagickFalse };
2972
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
2686
2973
  if (rm_should_raise_exception(&image->exception, RetainExceptionRetention))
2687
2974
  #endif
2688
2975
  {
@@ -2695,10 +2982,12 @@ set_profile(VALUE self, const char *name, VALUE profile)
2695
2982
  if (profile_data)
2696
2983
  {
2697
2984
  #if defined(IMAGEMAGICK_7)
2698
- ProfileImage(image, name, GetStringInfoDatum(profile_data), GetStringInfoLength(profile_data), exception);
2985
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, name, GetStringInfoDatum(profile_data), GetStringInfoLength(profile_data), exception };
2986
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
2699
2987
  if (rm_should_raise_exception(exception, RetainExceptionRetention))
2700
2988
  #else
2701
- ProfileImage(image, name, GetStringInfoDatum(profile_data), GetStringInfoLength(profile_data), MagickFalse);
2989
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, name, GetStringInfoDatum(profile_data), GetStringInfoLength(profile_data), MagickFalse };
2990
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
2702
2991
  if (rm_should_raise_exception(&image->exception, RetainExceptionRetention))
2703
2992
  #endif
2704
2993
  {
@@ -2847,12 +3136,14 @@ Image_color_flood_fill(VALUE self, VALUE target_color, VALUE fill_color,
2847
3136
 
2848
3137
  #if defined(IMAGEMAGICK_7)
2849
3138
  exception = AcquireExceptionInfo();
2850
- FloodfillPaintImage(new_image, draw_info, &target_mpp, x, y, invert, exception);
3139
+ GVL_STRUCT_TYPE(FloodfillPaintImage) args = { new_image, draw_info, &target_mpp, x, y, invert, exception };
3140
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FloodfillPaintImage), &args);
2851
3141
  DestroyDrawInfo(draw_info);
2852
3142
  rm_check_exception(exception, new_image, DestroyOnError);
2853
3143
  DestroyExceptionInfo(exception);
2854
3144
  #else
2855
- FloodfillPaintImage(new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert);
3145
+ GVL_STRUCT_TYPE(FloodfillPaintImage) args = { new_image, DefaultChannels, draw_info, &target_mpp, x, y, invert };
3146
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FloodfillPaintImage), &args);
2856
3147
 
2857
3148
  DestroyDrawInfo(draw_info);
2858
3149
  rm_check_image_exception(new_image, DestroyOnError);
@@ -2916,10 +3207,11 @@ Image_colorize(int argc, VALUE *argv, VALUE self)
2916
3207
 
2917
3208
  exception = AcquireExceptionInfo();
2918
3209
  #if defined(IMAGEMAGICK_7)
2919
- new_image = ColorizeImage(image, opacity, &target, exception);
3210
+ GVL_STRUCT_TYPE(ColorizeImage) args = { image, opacity, &target, exception };
2920
3211
  #else
2921
- new_image = ColorizeImage(image, opacity, target, exception);
3212
+ GVL_STRUCT_TYPE(ColorizeImage) args = { image, opacity, target, exception };
2922
3213
  #endif
3214
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ColorizeImage), &args);
2923
3215
  rm_check_exception(exception, new_image, DestroyOnError);
2924
3216
  DestroyExceptionInfo(exception);
2925
3217
 
@@ -3029,7 +3321,7 @@ Image_colormap(int argc, VALUE *argv, VALUE self)
3029
3321
  VALUE
3030
3322
  Image_colors(VALUE self)
3031
3323
  {
3032
- IMPLEMENT_ATTR_READER(Image, colors, ulong);
3324
+ IMPLEMENT_TYPED_ATTR_READER(Image, colors, ulong, &rm_image_data_type);
3033
3325
  }
3034
3326
 
3035
3327
  /**
@@ -3069,11 +3361,13 @@ Image_colorspace_eq(VALUE self, VALUE colorspace)
3069
3361
 
3070
3362
  #if defined(IMAGEMAGICK_7)
3071
3363
  exception = AcquireExceptionInfo();
3072
- TransformImageColorspace(image, new_cs, exception);
3364
+ GVL_STRUCT_TYPE(TransformImageColorspace) args = { image, new_cs, exception };
3365
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransformImageColorspace), &args);
3073
3366
  CHECK_EXCEPTION();
3074
3367
  DestroyExceptionInfo(exception);
3075
3368
  #else
3076
- TransformImageColorspace(image, new_cs);
3369
+ GVL_STRUCT_TYPE(TransformImageColorspace) args = { image, new_cs };
3370
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransformImageColorspace), &args);
3077
3371
  rm_check_image_exception(image, RetainOnError);
3078
3372
  #endif
3079
3373
 
@@ -3089,7 +3383,7 @@ Image_colorspace_eq(VALUE self, VALUE colorspace)
3089
3383
  VALUE
3090
3384
  Image_columns(VALUE self)
3091
3385
  {
3092
- IMPLEMENT_ATTR_READER(Image, columns, int);
3386
+ IMPLEMENT_TYPED_ATTR_READER(Image, columns, int, &rm_image_data_type);
3093
3387
  }
3094
3388
 
3095
3389
 
@@ -3104,17 +3398,17 @@ Image_columns(VALUE self)
3104
3398
  * @param channel [Magick::ChannelType] a ChannelType arguments.
3105
3399
  *
3106
3400
  * @overload compare_channel(image, metric, channel = Magick::AllChannels)
3107
- * If present a block, compare_channel yields to a block in which you can set optional arguments
3108
- * by setting attributes on self.
3109
- * - self.highlight_color = color
3401
+ * When a block is given, compare_channel yields with a block argument you can optionally use to
3402
+ * set attributes.
3403
+ * - options.highlight_color = color
3110
3404
  * - Emphasize pixel differences with this color. The default is partially transparent red.
3111
- * - self.lowlight_color = color
3405
+ * - options.lowlight_color = color
3112
3406
  * - Demphasize pixel differences with this color. The default is partially transparent white.
3113
3407
  * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
3114
3408
  * imagelist, uses the current image.
3115
3409
  * @param metric [Magick::MetricType] The desired distortion metric.
3116
3410
  * @param channel [Magick::ChannelType] a ChannelType arguments.
3117
- * @yield []
3411
+ * @yield [Magick::OptionalMethodArguments]
3118
3412
  *
3119
3413
  * @overload compare_channel(image, metric, *channels)
3120
3414
  * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
@@ -3124,18 +3418,18 @@ Image_columns(VALUE self)
3124
3418
  * @param *channels [Magick::ChannelType] one or more ChannelType arguments.
3125
3419
  *
3126
3420
  * @overload compare_channel(image, metric, *channels)
3127
- * If present a block, compare_channel yields to a block in which you can set optional arguments
3128
- * by setting attributes on self.
3129
- * - self.highlight_color = color
3421
+ * When a block is given, compare_channel yields with a block argument you can optionally use to
3422
+ * set attributes.
3423
+ * - options.highlight_color = color
3130
3424
  * - Emphasize pixel differences with this color. The default is partially transparent red.
3131
- * - self.lowlight_color = color
3425
+ * - options.lowlight_color = color
3132
3426
  * - Demphasize pixel differences with this color. The default is partially transparent white.
3133
3427
  * @param image [Magick::Image, Magick::ImageList] Either an imagelist or an image. If an
3134
3428
  * imagelist, uses the current image.
3135
3429
  * @param metric [Magick::MetricType] The desired distortion metric.
3136
3430
  * @param channel [Magick::ChannelType] a ChannelType arguments.
3137
3431
  * @param *channels [Magick::ChannelType] one or more ChannelType arguments.
3138
- * @yield []
3432
+ * @yield [Magick::OptionalMethodArguments]
3139
3433
  *
3140
3434
  * @return [Array] The first element is a difference image, the second is a the value of the
3141
3435
  * computed distortion represented as a Float.
@@ -3173,10 +3467,12 @@ Image_compare_channel(int argc, VALUE *argv, VALUE self)
3173
3467
  exception = AcquireExceptionInfo();
3174
3468
  #if defined(IMAGEMAGICK_7)
3175
3469
  BEGIN_CHANNEL_MASK(image, channels);
3176
- difference_image = CompareImages(image, r_image, metric_type, &distortion, exception);
3470
+ GVL_STRUCT_TYPE(CompareImages) args = { image, r_image, metric_type, &distortion, exception };
3471
+ difference_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImages), &args);
3177
3472
  END_CHANNEL_MASK(image);
3178
3473
  #else
3179
- difference_image = CompareImageChannels(image, r_image, channels, metric_type, &distortion, exception);
3474
+ GVL_STRUCT_TYPE(CompareImageChannels) args = { image, r_image, channels, metric_type, &distortion, exception };
3475
+ difference_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImageChannels), &args);
3180
3476
  #endif
3181
3477
  rm_check_exception(exception, difference_image, DestroyOnError);
3182
3478
  DestroyExceptionInfo(exception);
@@ -3374,12 +3670,14 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3374
3670
  #if defined(IMAGEMAGICK_7)
3375
3671
  exception = AcquireExceptionInfo();
3376
3672
  BEGIN_CHANNEL_MASK(image, channels);
3377
- CompositeImage(image, comp_image, operator, MagickTrue, x_offset, y_offset, exception);
3673
+ GVL_STRUCT_TYPE(CompositeImage) args = { image, comp_image, operator, MagickTrue, x_offset, y_offset, exception };
3674
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
3378
3675
  END_CHANNEL_MASK(image);
3379
3676
  CHECK_EXCEPTION();
3380
3677
  DestroyExceptionInfo(exception);
3381
3678
  #else
3382
- CompositeImageChannel(image, channels, operator, comp_image, x_offset, y_offset);
3679
+ GVL_STRUCT_TYPE(CompositeImageChannel) args = { image, channels, operator, comp_image, x_offset, y_offset };
3680
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
3383
3681
  rm_check_image_exception(image, RetainOnError);
3384
3682
  #endif
3385
3683
 
@@ -3392,12 +3690,14 @@ composite(int bang, int argc, VALUE *argv, VALUE self, ChannelType channels)
3392
3690
  #if defined(IMAGEMAGICK_7)
3393
3691
  exception = AcquireExceptionInfo();
3394
3692
  BEGIN_CHANNEL_MASK(new_image, channels);
3395
- CompositeImage(new_image, comp_image, operator, MagickTrue, x_offset, y_offset, exception);
3693
+ GVL_STRUCT_TYPE(CompositeImage) args = { new_image, comp_image, operator, MagickTrue, x_offset, y_offset, exception };
3694
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
3396
3695
  END_CHANNEL_MASK(new_image);
3397
3696
  rm_check_exception(exception, new_image, DestroyOnError);
3398
3697
  DestroyExceptionInfo(exception);
3399
3698
  #else
3400
- CompositeImageChannel(new_image, channels, operator, comp_image, x_offset, y_offset);
3699
+ GVL_STRUCT_TYPE(CompositeImageChannel) args = { new_image, channels, operator, comp_image, x_offset, y_offset };
3700
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
3401
3701
  rm_check_image_exception(new_image, DestroyOnError);
3402
3702
  #endif
3403
3703
 
@@ -3511,11 +3811,13 @@ Image_composite_affine(VALUE self, VALUE source, VALUE affine_matrix)
3511
3811
 
3512
3812
  #if defined(IMAGEMAGICK_7)
3513
3813
  exception = AcquireExceptionInfo();
3514
- DrawAffineImage(new_image, composite_image, &affine, exception);
3814
+ GVL_STRUCT_TYPE(DrawAffineImage) args = { new_image, composite_image, &affine, exception };
3815
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DrawAffineImage), &args);
3515
3816
  rm_check_exception(exception, new_image, DestroyOnError);
3516
3817
  DestroyExceptionInfo(exception);
3517
3818
  #else
3518
- DrawAffineImage(new_image, composite_image, &affine);
3819
+ GVL_STRUCT_TYPE(DrawAffineImage) args = { new_image, composite_image, &affine };
3820
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DrawAffineImage), &args);
3519
3821
  rm_check_image_exception(new_image, DestroyOnError);
3520
3822
  #endif
3521
3823
 
@@ -3879,11 +4181,13 @@ composite_tiled(int bang, int argc, VALUE *argv, VALUE self)
3879
4181
  {
3880
4182
  #if defined(IMAGEMAGICK_7)
3881
4183
  BEGIN_CHANNEL_MASK(image, channels);
3882
- status = CompositeImage(image, comp_image, operator, MagickTrue, x, y, exception);
4184
+ GVL_STRUCT_TYPE(CompositeImage) args = { image, comp_image, operator, MagickTrue, x, y, exception };
4185
+ status = (MagickStatusType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
3883
4186
  END_CHANNEL_MASK(image);
3884
4187
  rm_check_exception(exception, image, bang ? RetainOnError: DestroyOnError);
3885
4188
  #else
3886
- status = CompositeImageChannel(image, channels, operator, comp_image, x, y);
4189
+ GVL_STRUCT_TYPE(CompositeImageChannel) args = { image, channels, operator, comp_image, x, y };
4190
+ status = (MagickStatusType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImageChannel), &args);
3887
4191
  rm_check_image_exception(image, bang ? RetainOnError: DestroyOnError);
3888
4192
  #endif
3889
4193
  }
@@ -3996,11 +4300,13 @@ Image_compress_colormap_bang(VALUE self)
3996
4300
 
3997
4301
  #if defined(IMAGEMAGICK_7)
3998
4302
  exception = AcquireExceptionInfo();
3999
- okay = CompressImageColormap(image, exception);
4303
+ GVL_STRUCT_TYPE(CompressImageColormap) args = { image, exception };
4304
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
4000
4305
  CHECK_EXCEPTION();
4001
4306
  DestroyExceptionInfo(exception);
4002
4307
  #else
4003
- okay = CompressImageColormap(image);
4308
+ GVL_STRUCT_TYPE(CompressImageColormap) args = { image };
4309
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompressImageColormap), &args);
4004
4310
  rm_check_image_exception(image, RetainOnError);
4005
4311
  #endif
4006
4312
  if (!okay)
@@ -4130,9 +4436,11 @@ Image_constitute(VALUE class ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg
4130
4436
 
4131
4437
  #if defined(IMAGEMAGICK_7)
4132
4438
  exception = AcquireExceptionInfo();
4133
- SetImageExtent(new_image, width, height, exception);
4439
+ GVL_STRUCT_TYPE(SetImageExtent) args_SetImageExtent = { new_image, width, height, exception };
4440
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageExtent), &args_SetImageExtent);
4134
4441
  #else
4135
- SetImageExtent(new_image, width, height);
4442
+ GVL_STRUCT_TYPE(SetImageExtent) args_SetImageExtent = { new_image, width, height };
4443
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageExtent), &args_SetImageExtent);
4136
4444
  exception = &new_image->exception;
4137
4445
  #endif
4138
4446
 
@@ -4148,9 +4456,11 @@ Image_constitute(VALUE class ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg
4148
4456
  }
4149
4457
 
4150
4458
  #if defined(IMAGEMAGICK_7)
4151
- SetImageBackgroundColor(new_image, exception);
4459
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args_SetImageBackgroundColor = { new_image, exception };
4460
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args_SetImageBackgroundColor);
4152
4461
  #else
4153
- SetImageBackgroundColor(new_image);
4462
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args_SetImageBackgroundColor = { new_image };
4463
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args_SetImageBackgroundColor);
4154
4464
  exception = &new_image->exception;
4155
4465
  #endif
4156
4466
 
@@ -4166,12 +4476,14 @@ Image_constitute(VALUE class ATTRIBUTE_UNUSED, VALUE width_arg, VALUE height_arg
4166
4476
  }
4167
4477
 
4168
4478
  #if defined(IMAGEMAGICK_7)
4169
- ImportImagePixels(new_image, 0, 0, width, height, map, stg_type, (const void *)pixels.v, exception);
4479
+ GVL_STRUCT_TYPE(ImportImagePixels) args_ImportImagePixels = { new_image, 0, 0, width, height, map, stg_type, (const void *)pixels.v, exception };
4480
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args_ImportImagePixels);
4170
4481
  xfree(pixels.v);
4171
4482
  rm_check_exception(exception, new_image, DestroyOnError);
4172
4483
  DestroyExceptionInfo(exception);
4173
4484
  #else
4174
- ImportImagePixels(new_image, 0, 0, width, height, map, stg_type, (const void *)pixels.v);
4485
+ GVL_STRUCT_TYPE(ImportImagePixels) args_ImportImagePixels = { new_image, 0, 0, width, height, map, stg_type, (const void *)pixels.v };
4486
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args_ImportImagePixels);
4175
4487
  xfree(pixels.v);
4176
4488
  rm_check_image_exception(new_image, DestroyOnError);
4177
4489
  #endif
@@ -4338,12 +4650,14 @@ Image_contrast_stretch_channel(int argc, VALUE *argv, VALUE self)
4338
4650
  #if defined(IMAGEMAGICK_7)
4339
4651
  exception = AcquireExceptionInfo();
4340
4652
  BEGIN_CHANNEL_MASK(new_image, channels);
4341
- ContrastStretchImage(new_image, black_point, white_point, exception);
4653
+ GVL_STRUCT_TYPE(ContrastStretchImage) args = { new_image, black_point, white_point, exception };
4654
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ContrastStretchImage), &args);
4342
4655
  END_CHANNEL_MASK(new_image);
4343
4656
  CHECK_EXCEPTION();
4344
4657
  DestroyExceptionInfo(exception);
4345
4658
  #else
4346
- ContrastStretchImageChannel(new_image, channels, black_point, white_point);
4659
+ GVL_STRUCT_TYPE(ContrastStretchImageChannel) args = { new_image, channels, black_point, white_point };
4660
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ContrastStretchImageChannel), &args);
4347
4661
  rm_check_image_exception(new_image, DestroyOnError);
4348
4662
  #endif
4349
4663
 
@@ -4413,17 +4727,19 @@ Image_morphology_channel(VALUE self, VALUE channel_v, VALUE method_v, VALUE iter
4413
4727
  rb_raise(rb_eArgError, "expected String or Magick::KernelInfo");
4414
4728
  }
4415
4729
 
4416
- Data_Get_Struct(kernel_v, KernelInfo, kernel);
4730
+ TypedData_Get_Struct(kernel_v, KernelInfo, &rm_kernel_info_data_type, kernel);
4417
4731
 
4418
4732
  exception = AcquireExceptionInfo();
4419
4733
 
4420
4734
  #if defined(IMAGEMAGICK_7)
4421
4735
  BEGIN_CHANNEL_MASK(image, channel);
4422
- new_image = MorphologyImage(image, method, NUM2LONG(iterations), kernel, exception);
4736
+ GVL_STRUCT_TYPE(MorphologyImage) args = { image, method, NUM2LONG(iterations), kernel, exception };
4737
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MorphologyImage), &args);
4423
4738
  CHANGE_RESULT_CHANNEL_MASK(new_image);
4424
4739
  END_CHANNEL_MASK(image);
4425
4740
  #else
4426
- new_image = MorphologyImageChannel(image, channel, method, NUM2LONG(iterations), kernel, exception);
4741
+ GVL_STRUCT_TYPE(MorphologyImageChannel) args = { image, channel, method, NUM2LONG(iterations), kernel, exception };
4742
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(MorphologyImageChannel), &args);
4427
4743
  #endif
4428
4744
  rm_check_exception(exception, new_image, DestroyOnError);
4429
4745
  DestroyExceptionInfo(exception);
@@ -4534,10 +4850,12 @@ Image_convolve(VALUE self, VALUE order_arg, VALUE kernel_arg)
4534
4850
  exception = AcquireExceptionInfo();
4535
4851
 
4536
4852
  #if defined(IMAGEMAGICK_7)
4537
- new_image = ConvolveImage(image, kernel, exception);
4853
+ GVL_STRUCT_TYPE(ConvolveImage) args = { image, kernel, exception };
4854
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ConvolveImage), &args);
4538
4855
  DestroyKernelInfo(kernel);
4539
4856
  #else
4540
- new_image = ConvolveImage(image, order, kernel, exception);
4857
+ GVL_STRUCT_TYPE(ConvolveImage) args = { image, order, kernel, exception };
4858
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ConvolveImage), &args);
4541
4859
  xfree((void *)kernel);
4542
4860
  #endif
4543
4861
 
@@ -4626,12 +4944,14 @@ Image_convolve_channel(int argc, VALUE *argv, VALUE self)
4626
4944
 
4627
4945
  #if defined(IMAGEMAGICK_7)
4628
4946
  BEGIN_CHANNEL_MASK(image, channels);
4629
- new_image = ConvolveImage(image, kernel, exception);
4947
+ GVL_STRUCT_TYPE(ConvolveImage) args = { image, kernel, exception };
4948
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ConvolveImage), &args);
4630
4949
  CHANGE_RESULT_CHANNEL_MASK(new_image);
4631
4950
  END_CHANNEL_MASK(image);
4632
4951
  DestroyKernelInfo(kernel);
4633
4952
  #else
4634
- new_image = ConvolveImageChannel(image, channels, order, kernel, exception);
4953
+ GVL_STRUCT_TYPE(ConvolveImageChannel) args = { image, channels, order, kernel, exception };
4954
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ConvolveImageChannel), &args);
4635
4955
  xfree((void *)kernel);
4636
4956
  #endif
4637
4957
 
@@ -4681,26 +5001,26 @@ Image_init_copy(VALUE copy, VALUE orig)
4681
5001
  /**
4682
5002
  * Extract a region of the image defined by width, height, x, y.
4683
5003
  *
4684
- * @overload crop(reset = false, x, y, width, height)
4685
- * @param reset [Boolean] true if reset the cropped image page canvas and position
5004
+ * @overload crop(x, y, width, height, reset = false)
4686
5005
  * @param x [Numeric] x position of start of region
4687
5006
  * @param y [Numeric] y position of start of region
4688
5007
  * @param width [Numeric] width of region
4689
5008
  * @param height [Numeric] height of region
4690
- *
4691
- * @overload crop(reset = false, gravity, width, height)
4692
5009
  * @param reset [Boolean] true if reset the cropped image page canvas and position
5010
+ *
5011
+ * @overload crop(gravity, width, height, reset = false)
4693
5012
  * @param gravity [Magick::GravityType] the gravity type
4694
5013
  * @param width [Numeric] width of region
4695
5014
  * @param height [Numeric] height of region
4696
-
4697
- * @overload crop(reset = false, gravity, x, y, width, height)
4698
5015
  * @param reset [Boolean] true if reset the cropped image page canvas and position
5016
+
5017
+ * @overload crop(gravity, x, y, width, height, reset = false)
4699
5018
  * @param gravity [Magick::GravityType] the gravity type
4700
5019
  * @param x [Numeric] x position of start of region
4701
5020
  * @param y [Numeric] y position of start of region
4702
5021
  * @param width [Numeric] width of region
4703
5022
  * @param height [Numeric] height of region
5023
+ * @param reset [Boolean] true if reset the cropped image page canvas and position
4704
5024
  *
4705
5025
  * @return [Magick::Image] a new image
4706
5026
  * @see Image#crop!
@@ -4774,11 +5094,13 @@ Image_cycle_colormap(VALUE self, VALUE amount)
4774
5094
 
4775
5095
  #if defined(IMAGEMAGICK_7)
4776
5096
  exception = AcquireExceptionInfo();
4777
- CycleColormapImage(new_image, amt, exception);
5097
+ GVL_STRUCT_TYPE(CycleColormapImage) args = { new_image, amt, exception };
5098
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CycleColormapImage), &args);
4778
5099
  rm_check_exception(exception, new_image, DestroyOnError);
4779
5100
  DestroyExceptionInfo(exception);
4780
5101
  #else
4781
- CycleColormapImage(new_image, amt);
5102
+ GVL_STRUCT_TYPE(CycleColormapImage) args = { new_image, amt };
5103
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CycleColormapImage), &args);
4782
5104
  rm_check_image_exception(new_image, DestroyOnError);
4783
5105
  #endif
4784
5106
 
@@ -4913,7 +5235,8 @@ Image_decipher(VALUE self, VALUE passphrase)
4913
5235
 
4914
5236
  new_image = rm_clone_image(image);
4915
5237
 
4916
- okay = DecipherImage(new_image, pf, exception);
5238
+ GVL_STRUCT_TYPE(DecipherImage) args = { new_image, pf, exception };
5239
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DecipherImage), &args);
4917
5240
  rm_check_exception(exception, new_image, DestroyOnError);
4918
5241
  if (!okay)
4919
5242
  {
@@ -4980,7 +5303,7 @@ Image_define(VALUE self, VALUE artifact, VALUE value)
4980
5303
  VALUE
4981
5304
  Image_delay(VALUE self)
4982
5305
  {
4983
- IMPLEMENT_ATTR_READER(Image, delay, ulong);
5306
+ IMPLEMENT_TYPED_ATTR_READER(Image, delay, ulong, &rm_image_data_type);
4984
5307
  }
4985
5308
 
4986
5309
  /**
@@ -4993,7 +5316,7 @@ Image_delay(VALUE self)
4993
5316
  VALUE
4994
5317
  Image_delay_eq(VALUE self, VALUE val)
4995
5318
  {
4996
- IMPLEMENT_ATTR_WRITER(Image, delay, ulong);
5319
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, delay, ulong, &rm_image_data_type);
4997
5320
  }
4998
5321
 
4999
5322
 
@@ -5015,11 +5338,13 @@ Image_delete_compose_mask(VALUE self)
5015
5338
 
5016
5339
  #if defined(IMAGEMAGICK_7)
5017
5340
  exception = AcquireExceptionInfo();
5018
- SetImageMask(image, CompositePixelMask, NULL, exception);
5341
+ GVL_STRUCT_TYPE(SetImageMask) args = { image, CompositePixelMask, NULL, exception };
5342
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args);
5019
5343
  CHECK_EXCEPTION();
5020
5344
  DestroyExceptionInfo(exception);
5021
5345
  #else
5022
- SetImageMask(image, NULL);
5346
+ GVL_STRUCT_TYPE(SetImageMask) args = { image, NULL };
5347
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args);
5023
5348
  rm_check_image_exception(image, RetainOnError);
5024
5349
  #endif
5025
5350
 
@@ -5039,8 +5364,18 @@ VALUE
5039
5364
  Image_delete_profile(VALUE self, VALUE name)
5040
5365
  {
5041
5366
  Image *image = rm_check_frozen(self);
5042
- DeleteImageProfile(image, StringValueCStr(name));
5043
5367
 
5368
+ #if defined(IMAGEMAGICK_7)
5369
+ ExceptionInfo *exception = AcquireExceptionInfo();
5370
+
5371
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, StringValueCStr(name), NULL, 0, exception };
5372
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
5373
+ CHECK_EXCEPTION();
5374
+ DestroyExceptionInfo(exception);
5375
+ #else
5376
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, StringValueCStr(name), NULL, 0, MagickTrue };
5377
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
5378
+ #endif
5044
5379
  return self;
5045
5380
  }
5046
5381
 
@@ -5057,13 +5392,14 @@ VALUE
5057
5392
  Image_depth(VALUE self)
5058
5393
  {
5059
5394
  Image *image;
5060
- unsigned long depth = 0;
5395
+ size_t depth = 0;
5061
5396
  ExceptionInfo *exception;
5062
5397
 
5063
5398
  image = rm_check_destroyed(self);
5064
5399
  exception = AcquireExceptionInfo();
5065
5400
 
5066
- depth = GetImageDepth(image, exception);
5401
+ GVL_STRUCT_TYPE(GetImageDepth) args = { image, exception };
5402
+ depth = (size_t)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageDepth), &args);
5067
5403
  CHECK_EXCEPTION();
5068
5404
 
5069
5405
  DestroyExceptionInfo(exception);
@@ -5110,7 +5446,8 @@ Image_deskew(int argc, VALUE *argv, VALUE self)
5110
5446
  }
5111
5447
 
5112
5448
  exception = AcquireExceptionInfo();
5113
- new_image = DeskewImage(image, threshold, exception);
5449
+ GVL_STRUCT_TYPE(DeskewImage) args = { image, threshold, exception };
5450
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DeskewImage), &args);
5114
5451
  CHECK_EXCEPTION();
5115
5452
  DestroyExceptionInfo(exception);
5116
5453
 
@@ -5132,7 +5469,8 @@ Image_despeckle(VALUE self)
5132
5469
  image = rm_check_destroyed(self);
5133
5470
  exception = AcquireExceptionInfo();
5134
5471
 
5135
- new_image = DespeckleImage(image, exception);
5472
+ GVL_STRUCT_TYPE(DespeckleImage) args = { image, exception };
5473
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DespeckleImage), &args);
5136
5474
  rm_check_exception(exception, new_image, DestroyOnError);
5137
5475
  DestroyExceptionInfo(exception);
5138
5476
 
@@ -5151,7 +5489,7 @@ Image_destroy_bang(VALUE self)
5151
5489
  Image *image;
5152
5490
 
5153
5491
  rb_check_frozen(self);
5154
- Data_Get_Struct(self, Image, image);
5492
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
5155
5493
  rm_image_destroy(image);
5156
5494
  DATA_PTR(self) = NULL;
5157
5495
  return self;
@@ -5168,7 +5506,7 @@ Image_destroyed_q(VALUE self)
5168
5506
  {
5169
5507
  Image *image;
5170
5508
 
5171
- Data_Get_Struct(self, Image, image);
5509
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
5172
5510
  return image ? Qfalse : Qtrue;
5173
5511
  }
5174
5512
 
@@ -5197,6 +5535,7 @@ Image_difference(VALUE self, VALUE other)
5197
5535
  Image *image2;
5198
5536
  VALUE mean, nmean, nmax;
5199
5537
  #if defined(IMAGEMAGICK_7)
5538
+ double distortion;
5200
5539
  ExceptionInfo *exception;
5201
5540
  #endif
5202
5541
 
@@ -5206,11 +5545,13 @@ Image_difference(VALUE self, VALUE other)
5206
5545
 
5207
5546
  #if defined(IMAGEMAGICK_7)
5208
5547
  exception = AcquireExceptionInfo();
5209
- IsImagesEqual(image, image2, exception);
5548
+ GVL_STRUCT_TYPE(GetImageDistortion) args = { image, image2, MeanErrorPerPixelErrorMetric, &distortion, exception };
5549
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageDistortion), &args);
5210
5550
  CHECK_EXCEPTION();
5211
5551
  DestroyExceptionInfo(exception);
5212
5552
  #else
5213
- IsImagesEqual(image, image2);
5553
+ GVL_STRUCT_TYPE(IsImagesEqual) args = { image, image2 };
5554
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImagesEqual), &args);
5214
5555
  rm_check_image_exception(image, RetainOnError);
5215
5556
  #endif
5216
5557
 
@@ -5234,7 +5575,7 @@ Image_difference(VALUE self, VALUE other)
5234
5575
  VALUE
5235
5576
  Image_directory(VALUE self)
5236
5577
  {
5237
- IMPLEMENT_ATTR_READER(Image, directory, str);
5578
+ IMPLEMENT_TYPED_ATTR_READER(Image, directory, str, &rm_image_data_type);
5238
5579
  }
5239
5580
 
5240
5581
 
@@ -5359,10 +5700,11 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
5359
5700
  // Create the Ruby array for the pixels. Return this even if ExportImagePixels fails.
5360
5701
  pixels_ary = rb_ary_new();
5361
5702
 
5362
- Data_Get_Struct(self, Image, image);
5703
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
5363
5704
 
5364
5705
  exception = AcquireExceptionInfo();
5365
- okay = ExportImagePixels(image, x, y, columns, rows, map, stg_type, (void *)pixels.v, exception);
5706
+ GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x, y, columns, rows, map, stg_type, (void *)pixels.v, exception };
5707
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
5366
5708
 
5367
5709
  if (!okay)
5368
5710
  {
@@ -5421,7 +5763,7 @@ Image_display(VALUE self)
5421
5763
  }
5422
5764
 
5423
5765
  info_obj = rm_info_new();
5424
- Data_Get_Struct(info_obj, Info, info);
5766
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
5425
5767
 
5426
5768
  #if defined(IMAGEMAGICK_7)
5427
5769
  exception = AcquireExceptionInfo();
@@ -5551,17 +5893,16 @@ Image_dissolve(int argc, VALUE *argv, VALUE self)
5551
5893
  * the source image will be taken into account in the mapping.
5552
5894
  *
5553
5895
  * @overload distort(type, points, bestfit = false)
5554
- * If present a block, distort yields to a block in which you can set optional arguments by
5555
- * setting attributes on self.
5556
- * - self.define("distort:viewport", "WxH+X+Y")
5896
+ * When a block is given, distort yields with a block argument you can optionally use to set attributes.
5897
+ * - options.define("distort:viewport", "WxH+X+Y")
5557
5898
  * - Specify the size and offset of the generated viewport image of the distorted image space. W and
5558
5899
  * H are the width and height, and X and Y are the offset.
5559
- * - self.define("distort:scale", N)
5900
+ * - options.define("distort:scale", N)
5560
5901
  * - N is an integer factor. Scale the output image (viewport or otherwise) by that factor without
5561
5902
  * changing the viewed contents of the distorted image. This can be used either for
5562
5903
  * 'super-sampling' the image for a higher quality result, or for panning and zooming around
5563
5904
  * the image (with appropriate viewport changes, or post-distort cropping and resizing).
5564
- * - self.verbose(true)
5905
+ * - options.verbose(true)
5565
5906
  * - Attempt to output the internal coefficients, and the -fx equivalent to the distortion, for
5566
5907
  expert study, and debugging purposes. This many not be available for all distorts.
5567
5908
  * @param type [Magick::DistortMethod] a DistortMethod value
@@ -5570,13 +5911,13 @@ Image_dissolve(int argc, VALUE *argv, VALUE self)
5570
5911
  * image is adjusted to ensure the whole source image will just fit within the final destination
5571
5912
  * image, which will be sized and offset accordingly. Also in many cases the virtual offset of
5572
5913
  * the source image will be taken into account in the mapping.
5573
- * @yield []
5914
+ * @yield [Magick::OptionalMethodArguments]
5574
5915
  *
5575
5916
  * @return [Magick::Image] a new image
5576
5917
  * @example
5577
- * img.distort(Magick::ScaleRotateTranslateDistortion, [0]) do
5578
- * self.define "distort:viewport", "44x44+15+0"
5579
- * self.define "distort:scale", 2
5918
+ * img.distort(Magick::ScaleRotateTranslateDistortion, [0]) do |options|
5919
+ * options.define "distort:viewport", "44x44+15+0"
5920
+ * options.define "distort:scale", 2
5580
5921
  * end
5581
5922
  */
5582
5923
  VALUE
@@ -5625,7 +5966,8 @@ Image_distort(int argc, VALUE *argv, VALUE self)
5625
5966
  }
5626
5967
 
5627
5968
  exception = AcquireExceptionInfo();
5628
- new_image = DistortImage(image, distortion_method, npoints, points, bestfit, exception);
5969
+ GVL_STRUCT_TYPE(DistortImage) args = { image, distortion_method, npoints, points, bestfit, exception };
5970
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(DistortImage), &args);
5629
5971
  xfree(points);
5630
5972
  rm_check_exception(exception, new_image, DestroyOnError);
5631
5973
  DestroyExceptionInfo(exception);
@@ -5684,11 +6026,13 @@ Image_distortion_channel(int argc, VALUE *argv, VALUE self)
5684
6026
  exception = AcquireExceptionInfo();
5685
6027
  #if defined(IMAGEMAGICK_7)
5686
6028
  BEGIN_CHANNEL_MASK(image, channels);
5687
- difference_image = CompareImages(image, reconstruct, metric, &distortion, exception);
6029
+ GVL_STRUCT_TYPE(CompareImages) args = { image, reconstruct, metric, &distortion, exception };
6030
+ difference_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompareImages), &args);
5688
6031
  END_CHANNEL_MASK(image);
5689
6032
  DestroyImage(difference_image);
5690
6033
  #else
5691
- GetImageChannelDistortion(image, reconstruct, channels, metric, &distortion, exception);
6034
+ GVL_STRUCT_TYPE(GetImageChannelDistortion) args = { image, reconstruct, channels, metric, &distortion, exception };
6035
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageChannelDistortion), &args);
5692
6036
  #endif
5693
6037
 
5694
6038
  CHECK_EXCEPTION();
@@ -5728,7 +6072,8 @@ Image__dump(VALUE self, VALUE depth ATTRIBUTE_UNUSED)
5728
6072
  strlcpy(info->magick, image->magick, sizeof(info->magick));
5729
6073
 
5730
6074
  exception = AcquireExceptionInfo();
5731
- blob = ImageToBlob(info, image, &length, exception);
6075
+ GVL_STRUCT_TYPE(ImageToBlob) args = { info, image, &length, exception };
6076
+ blob = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImageToBlob), &args);
5732
6077
 
5733
6078
  // Free ImageInfo first - error handling may raise an exception
5734
6079
  DestroyImageInfo(info);
@@ -5774,7 +6119,7 @@ Image_dup(VALUE self)
5774
6119
  VALUE dup;
5775
6120
 
5776
6121
  rm_check_destroyed(self);
5777
- dup = Data_Wrap_Struct(CLASS_OF(self), NULL, rm_image_destroy, NULL);
6122
+ dup = TypedData_Wrap_Struct(CLASS_OF(self), &rm_image_data_type, NULL);
5778
6123
  RB_GC_GUARD(dup);
5779
6124
 
5780
6125
  return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
@@ -5856,7 +6201,8 @@ Image_edge(int argc, VALUE *argv, VALUE self)
5856
6201
 
5857
6202
  exception = AcquireExceptionInfo();
5858
6203
 
5859
- new_image = EdgeImage(image, radius, exception);
6204
+ GVL_STRUCT_TYPE(EdgeImage) args = { image, radius, exception };
6205
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EdgeImage), &args);
5860
6206
  rm_check_exception(exception, new_image, DestroyOnError);
5861
6207
  DestroyExceptionInfo(exception);
5862
6208
 
@@ -5864,6 +6210,9 @@ Image_edge(int argc, VALUE *argv, VALUE self)
5864
6210
  }
5865
6211
 
5866
6212
 
6213
+ // aliases for common use of structure types; BlurImage, CharcoalImage, EmbossImage, GaussianBlurImage, SharpenImage
6214
+ typedef GVL_STRUCT_TYPE(BlurImage) GVL_STRUCT_TYPE(effect_image);
6215
+
5867
6216
  /**
5868
6217
  * Call one of the effects methods.
5869
6218
  *
@@ -5876,7 +6225,7 @@ Image_edge(int argc, VALUE *argv, VALUE self)
5876
6225
  * @return a new image
5877
6226
  */
5878
6227
  static VALUE
5879
- effect_image(VALUE self, int argc, VALUE *argv, effector_t effector)
6228
+ effect_image(VALUE self, int argc, VALUE *argv, gvl_function_t fp)
5880
6229
  {
5881
6230
  Image *image, *new_image;
5882
6231
  ExceptionInfo *exception;
@@ -5903,7 +6252,8 @@ effect_image(VALUE self, int argc, VALUE *argv, effector_t effector)
5903
6252
  }
5904
6253
 
5905
6254
  exception = AcquireExceptionInfo();
5906
- new_image = (effector)(image, radius, sigma, exception);
6255
+ GVL_STRUCT_TYPE(effect_image) args = { image, radius, sigma, exception };
6256
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
5907
6257
  rm_check_exception(exception, new_image, DestroyOnError);
5908
6258
  DestroyExceptionInfo(exception);
5909
6259
 
@@ -5922,7 +6272,7 @@ effect_image(VALUE self, int argc, VALUE *argv, effector_t effector)
5922
6272
  VALUE
5923
6273
  Image_emboss(int argc, VALUE *argv, VALUE self)
5924
6274
  {
5925
- return effect_image(self, argc, argv, EmbossImage);
6275
+ return effect_image(self, argc, argv, GVL_FUNC(EmbossImage));
5926
6276
  }
5927
6277
 
5928
6278
 
@@ -5948,7 +6298,8 @@ Image_encipher(VALUE self, VALUE passphrase)
5948
6298
 
5949
6299
  new_image = rm_clone_image(image);
5950
6300
 
5951
- okay = EncipherImage(new_image, pf, exception);
6301
+ GVL_STRUCT_TYPE(EncipherImage) args = { new_image, pf, exception };
6302
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EncipherImage), &args);
5952
6303
  rm_check_exception(exception, new_image, DestroyOnError);
5953
6304
  if (!okay)
5954
6305
  {
@@ -6004,7 +6355,8 @@ Image_enhance(VALUE self)
6004
6355
  image = rm_check_destroyed(self);
6005
6356
  exception = AcquireExceptionInfo();
6006
6357
 
6007
- new_image = EnhanceImage(image, exception);
6358
+ GVL_STRUCT_TYPE(EnhanceImage) args = { image, exception };
6359
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EnhanceImage), &args);
6008
6360
  rm_check_exception(exception, new_image, DestroyOnError);
6009
6361
  DestroyExceptionInfo(exception);
6010
6362
 
@@ -6030,11 +6382,13 @@ Image_equalize(VALUE self)
6030
6382
 
6031
6383
  #if defined(IMAGEMAGICK_7)
6032
6384
  exception = AcquireExceptionInfo();
6033
- EqualizeImage(new_image, exception);
6385
+ GVL_STRUCT_TYPE(EqualizeImage) args = { new_image, exception };
6386
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImage), &args);
6034
6387
  rm_check_exception(exception, new_image, DestroyOnError);
6035
6388
  DestroyExceptionInfo(exception);
6036
6389
  #else
6037
- EqualizeImage(new_image);
6390
+ GVL_STRUCT_TYPE(EqualizeImage) args = { new_image };
6391
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImage), &args);
6038
6392
  rm_check_image_exception(new_image, DestroyOnError);
6039
6393
  #endif
6040
6394
 
@@ -6074,12 +6428,14 @@ Image_equalize_channel(int argc, VALUE *argv, VALUE self)
6074
6428
  #if defined(IMAGEMAGICK_7)
6075
6429
  exception = AcquireExceptionInfo();
6076
6430
  BEGIN_CHANNEL_MASK(new_image, channels);
6077
- EqualizeImage(new_image, exception);
6431
+ GVL_STRUCT_TYPE(EqualizeImage) args = { new_image, exception };
6432
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImage), &args);
6078
6433
  END_CHANNEL_MASK(new_image);
6079
6434
  rm_check_exception(exception, new_image, DestroyOnError);
6080
6435
  DestroyExceptionInfo(exception);
6081
6436
  #else
6082
- EqualizeImageChannel(new_image, channels);
6437
+ GVL_STRUCT_TYPE(EqualizeImageChannel) args = { new_image, channels };
6438
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImageChannel), &args);
6083
6439
 
6084
6440
  rm_check_image_exception(new_image, DestroyOnError);
6085
6441
  #endif
@@ -6105,11 +6461,13 @@ Image_erase_bang(VALUE self)
6105
6461
 
6106
6462
  #if defined(IMAGEMAGICK_7)
6107
6463
  exception = AcquireExceptionInfo();
6108
- SetImageBackgroundColor(image, exception);
6464
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image, exception };
6465
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
6109
6466
  CHECK_EXCEPTION();
6110
6467
  DestroyExceptionInfo(exception);
6111
6468
  #else
6112
- SetImageBackgroundColor(image);
6469
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image };
6470
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
6113
6471
  rm_check_image_exception(image, RetainOnError);
6114
6472
  #endif
6115
6473
 
@@ -6151,10 +6509,11 @@ excerpt(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
6151
6509
  rect.width = NUM2ULONG(width);
6152
6510
  rect.height = NUM2ULONG(height);
6153
6511
 
6154
- Data_Get_Struct(self, Image, image);
6512
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
6155
6513
 
6156
6514
  exception = AcquireExceptionInfo();
6157
- new_image = ExcerptImage(image, &rect, exception);
6515
+ GVL_STRUCT_TYPE(ExcerptImage) args = { image, &rect, exception };
6516
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExcerptImage), &args);
6158
6517
  rm_check_exception(exception, new_image, DestroyOnError);
6159
6518
  DestroyExceptionInfo(exception);
6160
6519
 
@@ -6242,7 +6601,7 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
6242
6601
  long x_off = 0L, y_off = 0L;
6243
6602
  unsigned long cols, rows;
6244
6603
  long n, npixels;
6245
- unsigned int okay;
6604
+ MagickBooleanType okay;
6246
6605
  const char *map = "RGB";
6247
6606
  Quantum *pixels;
6248
6607
  VALUE ary;
@@ -6289,7 +6648,8 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
6289
6648
 
6290
6649
  exception = AcquireExceptionInfo();
6291
6650
 
6292
- okay = ExportImagePixels(image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, exception);
6651
+ GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x_off, y_off, cols, rows, map, QuantumPixel, (void *)pixels, exception };
6652
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
6293
6653
  if (!okay)
6294
6654
  {
6295
6655
  xfree((void *)pixels);
@@ -6371,10 +6731,11 @@ Image_extent(int argc, VALUE *argv, VALUE self)
6371
6731
  }
6372
6732
 
6373
6733
 
6374
- Data_Get_Struct(self, Image, image);
6734
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
6375
6735
  exception = AcquireExceptionInfo();
6376
6736
 
6377
- new_image = ExtentImage(image, &geometry, exception);
6737
+ GVL_STRUCT_TYPE(ExtentImage) args = { image, &geometry, exception };
6738
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExtentImage), &args);
6378
6739
  rm_check_exception(exception, new_image, DestroyOnError);
6379
6740
  DestroyExceptionInfo(exception);
6380
6741
 
@@ -6406,7 +6767,7 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6406
6767
  unsigned long cols, rows;
6407
6768
  unsigned long npixels;
6408
6769
  size_t sz;
6409
- unsigned int okay;
6770
+ MagickBooleanType okay;
6410
6771
  const char *map = "RGB";
6411
6772
  StorageType type = CharPixel;
6412
6773
  VALUE string;
@@ -6479,7 +6840,8 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6479
6840
 
6480
6841
  exception = AcquireExceptionInfo();
6481
6842
 
6482
- okay = ExportImagePixels(image, x_off, y_off, cols, rows, map, type, (void *)RSTRING_PTR(string), exception);
6843
+ GVL_STRUCT_TYPE(ExportImagePixels) args = { image, x_off, y_off, cols, rows, map, type, (void *)RSTRING_PTR(string), exception };
6844
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ExportImagePixels), &args);
6483
6845
  if (!okay)
6484
6846
  {
6485
6847
  // Let GC have the string buffer.
@@ -6534,7 +6896,7 @@ Image_extract_info_eq(VALUE self, VALUE rect)
6534
6896
  VALUE
6535
6897
  Image_filename(VALUE self)
6536
6898
  {
6537
- IMPLEMENT_ATTR_READER(Image, filename, str);
6899
+ IMPLEMENT_TYPED_ATTR_READER(Image, filename, str, &rm_image_data_type);
6538
6900
  }
6539
6901
 
6540
6902
 
@@ -6601,7 +6963,7 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6601
6963
  VALUE region, targ;
6602
6964
  ssize_t x = 0L, y = 0L;
6603
6965
  ExceptionInfo *exception;
6604
- unsigned int okay;
6966
+ MagickBooleanType okay;
6605
6967
 
6606
6968
  image = rm_check_destroyed(self);
6607
6969
 
@@ -6621,7 +6983,13 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6621
6983
  }
6622
6984
 
6623
6985
  exception = AcquireExceptionInfo();
6624
- okay = IsEquivalentImage(image, target, &x, &y, exception);
6986
+ #if defined(IMAGEMAGICK_7)
6987
+ GVL_STRUCT_TYPE(IsEquivalentImage) args = { image, target, &x, &y, exception };
6988
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsEquivalentImage), &args);
6989
+ #else
6990
+ GVL_STRUCT_TYPE(IsImageSimilar) args = { image, target, &x, &y, exception };
6991
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImageSimilar), &args);
6992
+ #endif
6625
6993
  CHECK_EXCEPTION();
6626
6994
  DestroyExceptionInfo(exception);
6627
6995
 
@@ -6641,6 +7009,9 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6641
7009
  }
6642
7010
 
6643
7011
 
7012
+ // aliases for common use of structure types; FlopImage, FlipImage
7013
+ typedef GVL_STRUCT_TYPE(FlipImage) GVL_STRUCT_TYPE(flipflop);
7014
+
6644
7015
  /**
6645
7016
  * Call a flipflopper (a function that either flips or flops the image).
6646
7017
  *
@@ -6656,15 +7027,16 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6656
7027
  * @see Image_flop_bang
6657
7028
  */
6658
7029
  static VALUE
6659
- flipflop(int bang, VALUE self, flipper_t flipflopper)
7030
+ flipflop(int bang, VALUE self, gvl_function_t fp)
6660
7031
  {
6661
7032
  Image *image, *new_image;
6662
7033
  ExceptionInfo *exception;
6663
7034
 
6664
- Data_Get_Struct(self, Image, image);
7035
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
6665
7036
  exception = AcquireExceptionInfo();
6666
7037
 
6667
- new_image = (flipflopper)(image, exception);
7038
+ GVL_STRUCT_TYPE(flipflop) args = { image, exception };
7039
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
6668
7040
  rm_check_exception(exception, new_image, DestroyOnError);
6669
7041
  DestroyExceptionInfo(exception);
6670
7042
 
@@ -6692,7 +7064,7 @@ VALUE
6692
7064
  Image_flip(VALUE self)
6693
7065
  {
6694
7066
  rm_check_destroyed(self);
6695
- return flipflop(False, self, FlipImage);
7067
+ return flipflop(False, self, GVL_FUNC(FlipImage));
6696
7068
  }
6697
7069
 
6698
7070
 
@@ -6709,7 +7081,7 @@ VALUE
6709
7081
  Image_flip_bang(VALUE self)
6710
7082
  {
6711
7083
  rm_check_frozen(self);
6712
- return flipflop(True, self, FlipImage);
7084
+ return flipflop(True, self, GVL_FUNC(FlipImage));
6713
7085
  }
6714
7086
 
6715
7087
 
@@ -6725,7 +7097,7 @@ VALUE
6725
7097
  Image_flop(VALUE self)
6726
7098
  {
6727
7099
  rm_check_destroyed(self);
6728
- return flipflop(False, self, FlopImage);
7100
+ return flipflop(False, self, GVL_FUNC(FlopImage));
6729
7101
  }
6730
7102
 
6731
7103
 
@@ -6742,7 +7114,7 @@ VALUE
6742
7114
  Image_flop_bang(VALUE self)
6743
7115
  {
6744
7116
  rm_check_frozen(self);
6745
- return flipflop(True, self, FlopImage);
7117
+ return flipflop(True, self, GVL_FUNC(FlopImage));
6746
7118
  }
6747
7119
 
6748
7120
 
@@ -6862,10 +7234,11 @@ Image_frame(int argc, VALUE *argv, VALUE self)
6862
7234
 
6863
7235
  exception = AcquireExceptionInfo();
6864
7236
  #if defined(IMAGEMAGICK_7)
6865
- new_image = FrameImage(image, &frame_info, image->compose, exception);
7237
+ GVL_STRUCT_TYPE(FrameImage) args = { image, &frame_info, image->compose, exception };
6866
7238
  #else
6867
- new_image = FrameImage(image, &frame_info, exception);
7239
+ GVL_STRUCT_TYPE(FrameImage) args = { image, &frame_info, exception };
6868
7240
  #endif
7241
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FrameImage), &args);
6869
7242
  rm_check_exception(exception, new_image, DestroyOnError);
6870
7243
  DestroyExceptionInfo(exception);
6871
7244
 
@@ -6882,7 +7255,7 @@ Image_frame(int argc, VALUE *argv, VALUE self)
6882
7255
  * @overload from_blob(blob)
6883
7256
  * This yields {Magick::Image::Info} to block with its object's scope.
6884
7257
  * @param blob [String] the blob data
6885
- * @yield []
7258
+ * @yield [Magick::Image::Info]
6886
7259
  *
6887
7260
  * @return [Array<Magick::Image>] an array of new images
6888
7261
  * @see Image#to_blob
@@ -6901,10 +7274,11 @@ Image_from_blob(VALUE class ATTRIBUTE_UNUSED, VALUE blob_arg)
6901
7274
 
6902
7275
  // Get a new Info object - run the parm block if supplied
6903
7276
  info_obj = rm_info_new();
6904
- Data_Get_Struct(info_obj, Info, info);
7277
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
6905
7278
 
6906
7279
  exception = AcquireExceptionInfo();
6907
- images = BlobToImage(info, blob, (size_t)length, exception);
7280
+ GVL_STRUCT_TYPE(BlobToImage) args = { info, blob, (size_t)length, exception };
7281
+ images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
6908
7282
  rm_check_exception(exception, images, DestroyOnError);
6909
7283
 
6910
7284
  DestroyExceptionInfo(exception);
@@ -7004,10 +7378,12 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
7004
7378
  new_image = rm_clone_image(image);
7005
7379
  #if defined(IMAGEMAGICK_7)
7006
7380
  BEGIN_CHANNEL_MASK(new_image, channels);
7007
- FunctionImage(new_image, function, nparms, parms, exception);
7381
+ GVL_STRUCT_TYPE(FunctionImage) args = { new_image, function, nparms, parms, exception };
7382
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FunctionImage), &args);
7008
7383
  END_CHANNEL_MASK(new_image);
7009
7384
  #else
7010
- FunctionImageChannel(new_image, channels, function, nparms, parms, exception);
7385
+ GVL_STRUCT_TYPE(FunctionImageChannel) args = { new_image, channels, function, nparms, parms, exception };
7386
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FunctionImageChannel), &args);
7011
7387
  #endif
7012
7388
  xfree(parms);
7013
7389
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -7028,7 +7404,7 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
7028
7404
  VALUE
7029
7405
  Image_fuzz(VALUE self)
7030
7406
  {
7031
- IMPLEMENT_ATTR_READER(Image, fuzz, dbl);
7407
+ IMPLEMENT_TYPED_ATTR_READER(Image, fuzz, dbl, &rm_image_data_type);
7032
7408
  }
7033
7409
 
7034
7410
 
@@ -7088,11 +7464,13 @@ Image_fx(int argc, VALUE *argv, VALUE self)
7088
7464
  exception = AcquireExceptionInfo();
7089
7465
  #if defined(IMAGEMAGICK_7)
7090
7466
  BEGIN_CHANNEL_MASK(image, channels);
7091
- new_image = FxImage(image, expression, exception);
7467
+ GVL_STRUCT_TYPE(FxImage) args = { image, expression, exception };
7468
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FxImage), &args);
7092
7469
  CHANGE_RESULT_CHANNEL_MASK(new_image);
7093
7470
  END_CHANNEL_MASK(image);
7094
7471
  #else
7095
- new_image = FxImageChannel(image, channels, expression, exception);
7472
+ GVL_STRUCT_TYPE(FxImageChannel) args = { image, channels, expression, exception };
7473
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FxImageChannel), &args);
7096
7474
  #endif
7097
7475
  rm_check_exception(exception, new_image, DestroyOnError);
7098
7476
  DestroyExceptionInfo(exception);
@@ -7108,7 +7486,7 @@ Image_fx(int argc, VALUE *argv, VALUE self)
7108
7486
  VALUE
7109
7487
  Image_gamma(VALUE self)
7110
7488
  {
7111
- IMPLEMENT_ATTR_READER(Image, gamma, dbl);
7489
+ IMPLEMENT_TYPED_ATTR_READER(Image, gamma, dbl, &rm_image_data_type);
7112
7490
  }
7113
7491
 
7114
7492
  /**
@@ -7120,7 +7498,7 @@ Image_gamma(VALUE self)
7120
7498
  VALUE
7121
7499
  Image_gamma_eq(VALUE self, VALUE val)
7122
7500
  {
7123
- IMPLEMENT_ATTR_WRITER(Image, gamma, dbl);
7501
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, gamma, dbl, &rm_image_data_type);
7124
7502
  }
7125
7503
 
7126
7504
 
@@ -7168,12 +7546,14 @@ Image_gamma_channel(int argc, VALUE *argv, VALUE self)
7168
7546
  #if defined(IMAGEMAGICK_7)
7169
7547
  exception = AcquireExceptionInfo();
7170
7548
  BEGIN_CHANNEL_MASK(new_image, channels);
7171
- GammaImage(new_image, gamma, exception);
7549
+ GVL_STRUCT_TYPE(GammaImage) args = { new_image, gamma, exception };
7550
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImage), &args);
7172
7551
  END_CHANNEL_MASK(new_image);
7173
7552
  rm_check_exception(exception, new_image, DestroyOnError);
7174
7553
  DestroyExceptionInfo(exception);
7175
7554
  #else
7176
- GammaImageChannel(new_image, channels, gamma);
7555
+ GVL_STRUCT_TYPE(GammaImageChannel) args = { new_image, channels, gamma };
7556
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImageChannel), &args);
7177
7557
  rm_check_image_exception(new_image, DestroyOnError);
7178
7558
  #endif
7179
7559
 
@@ -7229,30 +7609,40 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
7229
7609
  {
7230
7610
  #if defined(IMAGEMAGICK_7)
7231
7611
  BEGIN_CHANNEL_MASK(new_image, (ChannelType) (RedChannel | GreenChannel | BlueChannel));
7232
- GammaImage(new_image, red_gamma, exception);
7612
+ GVL_STRUCT_TYPE(GammaImage) args = { new_image, red_gamma, exception };
7613
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImage), &args);
7233
7614
  END_CHANNEL_MASK(new_image);
7234
7615
  #else
7235
- GammaImageChannel(new_image, (ChannelType) (RedChannel | GreenChannel | BlueChannel), red_gamma);
7616
+ GVL_STRUCT_TYPE(GammaImageChannel) args = { new_image, (ChannelType) (RedChannel | GreenChannel | BlueChannel), red_gamma };
7617
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImageChannel), &args);
7236
7618
  #endif
7237
7619
  }
7238
7620
  else
7239
7621
  {
7240
7622
  #if defined(IMAGEMAGICK_7)
7241
7623
  BEGIN_CHANNEL_MASK(new_image, RedChannel);
7242
- GammaImage(new_image, red_gamma, exception);
7624
+ GVL_STRUCT_TYPE(GammaImage) args1 = { new_image, red_gamma, exception };
7625
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImage), &args1);
7243
7626
  END_CHANNEL_MASK(new_image);
7244
7627
 
7245
7628
  BEGIN_CHANNEL_MASK(new_image, GreenChannel);
7246
- GammaImage(new_image, green_gamma, exception);
7629
+ GVL_STRUCT_TYPE(GammaImage) args2 = { new_image, green_gamma, exception };
7630
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImage), &args2);
7247
7631
  END_CHANNEL_MASK(new_image);
7248
7632
 
7249
7633
  BEGIN_CHANNEL_MASK(new_image, BlueChannel);
7250
- GammaImage(new_image, blue_gamma, exception);
7634
+ GVL_STRUCT_TYPE(GammaImage) args3 = { new_image, blue_gamma, exception };
7635
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImage), &args3);
7251
7636
  END_CHANNEL_MASK(new_image);
7252
7637
  #else
7253
- GammaImageChannel(new_image, RedChannel, red_gamma);
7254
- GammaImageChannel(new_image, GreenChannel, green_gamma);
7255
- GammaImageChannel(new_image, BlueChannel, blue_gamma);
7638
+ GVL_STRUCT_TYPE(GammaImageChannel) args1 = { new_image, RedChannel, red_gamma };
7639
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImageChannel), &args1);
7640
+
7641
+ GVL_STRUCT_TYPE(GammaImageChannel) args2 = { new_image, GreenChannel, green_gamma };
7642
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImageChannel), &args2);
7643
+
7644
+ GVL_STRUCT_TYPE(GammaImageChannel) args3 = { new_image, BlueChannel, blue_gamma };
7645
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImageChannel), &args3);
7256
7646
  #endif
7257
7647
  }
7258
7648
 
@@ -7278,7 +7668,7 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
7278
7668
  VALUE
7279
7669
  Image_gaussian_blur(int argc, VALUE *argv, VALUE self)
7280
7670
  {
7281
- return effect_image(self, argc, argv, GaussianBlurImage);
7671
+ return effect_image(self, argc, argv, GVL_FUNC(GaussianBlurImage));
7282
7672
  }
7283
7673
 
7284
7674
 
@@ -7326,12 +7716,14 @@ Image_gaussian_blur_channel(int argc, VALUE *argv, VALUE self)
7326
7716
  exception = AcquireExceptionInfo();
7327
7717
  #if defined(IMAGEMAGICK_7)
7328
7718
  BEGIN_CHANNEL_MASK(image, channels);
7329
- new_image = GaussianBlurImage(image, radius, sigma, exception);
7719
+ GVL_STRUCT_TYPE(GaussianBlurImage) args = { image, radius, sigma, exception };
7720
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GaussianBlurImage), &args);
7330
7721
  CHANGE_RESULT_CHANNEL_MASK(new_image);
7331
7722
  END_CHANNEL_MASK(image);
7332
7723
  rm_check_exception(exception, new_image, DestroyOnError);
7333
7724
  #else
7334
- new_image = GaussianBlurImageChannel(image, channels, radius, sigma, exception);
7725
+ GVL_STRUCT_TYPE(GaussianBlurImageChannel) args = { image, channels, radius, sigma, exception };
7726
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GaussianBlurImageChannel), &args);
7335
7727
  rm_check_exception(exception, new_image, DestroyOnError);
7336
7728
  #endif
7337
7729
 
@@ -7350,7 +7742,7 @@ Image_gaussian_blur_channel(int argc, VALUE *argv, VALUE self)
7350
7742
  VALUE
7351
7743
  Image_geometry(VALUE self)
7352
7744
  {
7353
- IMPLEMENT_ATTR_READER(Image, geometry, str);
7745
+ IMPLEMENT_TYPED_ATTR_READER(Image, geometry, str, &rm_image_data_type);
7354
7746
  }
7355
7747
 
7356
7748
 
@@ -7434,7 +7826,8 @@ Image_get_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE row
7434
7826
  // Cast AcquireImagePixels to get rid of the const qualifier. We're not going
7435
7827
  // to change the pixels but I don't want to make "pixels" const.
7436
7828
  exception = AcquireExceptionInfo();
7437
- pixels = GetVirtualPixels(image, x, y, columns, rows, exception);
7829
+ GVL_STRUCT_TYPE(GetVirtualPixels) args = { image, x, y, columns, rows, exception };
7830
+ pixels = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args);
7438
7831
  CHECK_EXCEPTION();
7439
7832
 
7440
7833
  DestroyExceptionInfo(exception);
@@ -7611,10 +8004,11 @@ Image_implode(int argc, VALUE *argv, VALUE self)
7611
8004
  exception = AcquireExceptionInfo();
7612
8005
 
7613
8006
  #if defined(IMAGEMAGICK_7)
7614
- new_image = ImplodeImage(image, amount, image->interpolate, exception);
8007
+ GVL_STRUCT_TYPE(ImplodeImage) args = { image, amount, image->interpolate, exception };
7615
8008
  #else
7616
- new_image = ImplodeImage(image, amount, exception);
8009
+ GVL_STRUCT_TYPE(ImplodeImage) args = { image, amount, exception };
7617
8010
  #endif
8011
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImplodeImage), &args);
7618
8012
  rm_check_exception(exception, new_image, DestroyOnError);
7619
8013
  DestroyExceptionInfo(exception);
7620
8014
 
@@ -7654,7 +8048,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
7654
8048
  Quantum *pixels = NULL;
7655
8049
  double *fpixels = NULL;
7656
8050
  void *buffer;
7657
- unsigned int okay;
8051
+ MagickBooleanType okay;
7658
8052
  #if defined(IMAGEMAGICK_7)
7659
8053
  ExceptionInfo *exception;
7660
8054
  #endif
@@ -7791,10 +8185,11 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
7791
8185
 
7792
8186
  #if defined(IMAGEMAGICK_7)
7793
8187
  exception = AcquireExceptionInfo();
7794
- okay = ImportImagePixels(image, x_off, y_off, cols, rows, map, stg_type, buffer, exception);
8188
+ GVL_STRUCT_TYPE(ImportImagePixels) args = { image, x_off, y_off, cols, rows, map, stg_type, buffer, exception };
7795
8189
  #else
7796
- okay = ImportImagePixels(image, x_off, y_off, cols, rows, map, stg_type, buffer);
8190
+ GVL_STRUCT_TYPE(ImportImagePixels) args = { image, x_off, y_off, cols, rows, map, stg_type, buffer };
7797
8191
  #endif
8192
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args);
7798
8193
 
7799
8194
  // Free pixel array before checking for errors.
7800
8195
  if (pixels)
@@ -7981,7 +8376,7 @@ Image_inspect(VALUE self)
7981
8376
  Image *image;
7982
8377
  char buffer[MaxTextExtent]; // image description buffer
7983
8378
 
7984
- Data_Get_Struct(self, Image, image);
8379
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
7985
8380
  if (!image)
7986
8381
  {
7987
8382
  return rb_str_new2("#<Magick::Image: (destroyed)>");
@@ -8074,12 +8469,12 @@ Image_iptc_profile_eq(VALUE self, VALUE profile)
8074
8469
  VALUE
8075
8470
  Image_iterations(VALUE self)
8076
8471
  {
8077
- IMPLEMENT_ATTR_READER(Image, iterations, int);
8472
+ IMPLEMENT_TYPED_ATTR_READER(Image, iterations, int, &rm_image_data_type);
8078
8473
  }
8079
8474
  VALUE
8080
8475
  Image_iterations_eq(VALUE self, VALUE val)
8081
8476
  {
8082
- IMPLEMENT_ATTR_WRITER(Image, iterations, int);
8477
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, iterations, int, &rm_image_data_type);
8083
8478
  }
8084
8479
 
8085
8480
  /**
@@ -8130,12 +8525,14 @@ Image_level2(int argc, VALUE *argv, VALUE self)
8130
8525
 
8131
8526
  #if defined(IMAGEMAGICK_7)
8132
8527
  exception = AcquireExceptionInfo();
8133
- LevelImage(new_image, black_point, white_point, gamma_val, exception);
8528
+ GVL_STRUCT_TYPE(LevelImage) args = { new_image, black_point, white_point, gamma_val, exception };
8529
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImage), &args);
8134
8530
  rm_check_exception(exception, new_image, DestroyOnError);
8135
8531
  DestroyExceptionInfo(exception);
8136
8532
  #else
8137
8533
  snprintf(level, sizeof(level), "%gx%g+%g", black_point, white_point, gamma_val);
8138
- LevelImage(new_image, level);
8534
+ GVL_STRUCT_TYPE(LevelImage) args = { new_image, level };
8535
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImage), &args);
8139
8536
  rm_check_image_exception(new_image, DestroyOnError);
8140
8537
  #endif
8141
8538
 
@@ -8194,12 +8591,14 @@ Image_level_channel(int argc, VALUE *argv, VALUE self)
8194
8591
  #if defined(IMAGEMAGICK_7)
8195
8592
  exception = AcquireExceptionInfo();
8196
8593
  BEGIN_CHANNEL_MASK(new_image, channel);
8197
- LevelImage(new_image, black_point, white_point, gamma_val, exception);
8594
+ GVL_STRUCT_TYPE(LevelImage) args = { new_image, black_point, white_point, gamma_val, exception };
8595
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImage), &args);
8198
8596
  END_CHANNEL_MASK(new_image);
8199
8597
  rm_check_exception(exception, new_image, DestroyOnError);
8200
8598
  DestroyExceptionInfo(exception);
8201
8599
  #else
8202
- LevelImageChannel(new_image, channel, black_point, white_point, gamma_val);
8600
+ GVL_STRUCT_TYPE(LevelImageChannel) args = { new_image, channel, black_point, white_point, gamma_val };
8601
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImageChannel), &args);
8203
8602
  rm_check_image_exception(new_image, DestroyOnError);
8204
8603
  #endif
8205
8604
 
@@ -8275,12 +8674,14 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
8275
8674
  #if defined(IMAGEMAGICK_7)
8276
8675
  exception = AcquireExceptionInfo();
8277
8676
  BEGIN_CHANNEL_MASK(new_image, channels);
8278
- status = LevelImageColors(new_image, &black_color, &white_color, invert, exception);
8677
+ GVL_STRUCT_TYPE(LevelImageColors) args = { new_image, &black_color, &white_color, invert, exception };
8678
+ status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImageColors), &args);
8279
8679
  END_CHANNEL_MASK(new_image);
8280
8680
  rm_check_exception(exception, new_image, DestroyOnError);
8281
8681
  DestroyExceptionInfo(exception);
8282
8682
  #else
8283
- status = LevelColorsImageChannel(new_image, channels, &black_color, &white_color, invert);
8683
+ GVL_STRUCT_TYPE(LevelColorsImageChannel) args = { new_image, channels, &black_color, &white_color, invert };
8684
+ status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelColorsImageChannel), &args);
8284
8685
  rm_check_image_exception(new_image, DestroyOnError);
8285
8686
  #endif
8286
8687
  if (!status)
@@ -8350,12 +8751,14 @@ Image_levelize_channel(int argc, VALUE *argv, VALUE self)
8350
8751
  #if defined(IMAGEMAGICK_7)
8351
8752
  exception = AcquireExceptionInfo();
8352
8753
  BEGIN_CHANNEL_MASK(new_image, channels);
8353
- status = LevelizeImage(new_image, black_point, white_point, gamma, exception);
8754
+ GVL_STRUCT_TYPE(LevelizeImage) args = { new_image, black_point, white_point, gamma, exception };
8755
+ status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImage), &args);
8354
8756
  END_CHANNEL_MASK(new_image);
8355
8757
  rm_check_exception(exception, new_image, DestroyOnError);
8356
8758
  DestroyExceptionInfo(exception);
8357
8759
  #else
8358
- status = LevelizeImageChannel(new_image, channels, black_point, white_point, gamma);
8760
+ GVL_STRUCT_TYPE(LevelizeImageChannel) args = { new_image, channels, black_point, white_point, gamma };
8761
+ status = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelizeImageChannel), &args);
8359
8762
  rm_check_image_exception(new_image, DestroyOnError);
8360
8763
  #endif
8361
8764
 
@@ -8396,11 +8799,13 @@ Image_linear_stretch(int argc, VALUE *argv, VALUE self)
8396
8799
 
8397
8800
  #if defined(IMAGEMAGICK_7)
8398
8801
  exception = AcquireExceptionInfo();
8399
- LinearStretchImage(new_image, black_point, white_point, exception);
8802
+ GVL_STRUCT_TYPE(LinearStretchImage) args = { new_image, black_point, white_point, exception };
8803
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LinearStretchImage), &args);
8400
8804
  rm_check_exception(exception, new_image, DestroyOnError);
8401
8805
  DestroyExceptionInfo(exception);
8402
8806
  #else
8403
- LinearStretchImage(new_image, black_point, white_point);
8807
+ GVL_STRUCT_TYPE(LinearStretchImage) args = { new_image, black_point, white_point };
8808
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LinearStretchImage), &args);
8404
8809
  rm_check_image_exception(new_image, DestroyOnError);
8405
8810
  #endif
8406
8811
 
@@ -8446,7 +8851,8 @@ Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
8446
8851
  }
8447
8852
 
8448
8853
  exception = AcquireExceptionInfo();
8449
- new_image = LiquidRescaleImage(image, cols, rows, delta_x, rigidity, exception);
8854
+ GVL_STRUCT_TYPE(LiquidRescaleImage) args = { image, cols, rows, delta_x, rigidity, exception };
8855
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LiquidRescaleImage), &args);
8450
8856
  rm_check_exception(exception, new_image, DestroyOnError);
8451
8857
  DestroyExceptionInfo(exception);
8452
8858
 
@@ -8514,7 +8920,8 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8514
8920
 
8515
8921
  blob += offsetof(DumpedImage, magick) + mi.len;
8516
8922
  length -= offsetof(DumpedImage, magick) + mi.len;
8517
- image = BlobToImage(info, blob, (size_t) length, exception);
8923
+ GVL_STRUCT_TYPE(BlobToImage) args = { info, blob, (size_t)length, exception };
8924
+ image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
8518
8925
  DestroyImageInfo(info);
8519
8926
 
8520
8927
  rm_check_exception(exception, image, DestroyOnError);
@@ -8524,6 +8931,9 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8524
8931
  }
8525
8932
 
8526
8933
 
8934
+ // aliases for common use of structure types; MagnifyImage, MinifyImage
8935
+ typedef GVL_STRUCT_TYPE(MagnifyImage) GVL_STRUCT_TYPE(magnify);
8936
+
8527
8937
  /**
8528
8938
  * Scale an image proportionally to twice its size.
8529
8939
  *
@@ -8535,16 +8945,17 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8535
8945
  * @return self if bang, otherwise a new image
8536
8946
  */
8537
8947
  static VALUE
8538
- magnify(int bang, VALUE self, magnifier_t magnifier)
8948
+ magnify(int bang, VALUE self, gvl_function_t fp)
8539
8949
  {
8540
8950
  Image *image;
8541
8951
  Image *new_image;
8542
8952
  ExceptionInfo *exception;
8543
8953
 
8544
- Data_Get_Struct(self, Image, image);
8954
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
8545
8955
  exception = AcquireExceptionInfo();
8546
8956
 
8547
- new_image = (magnifier)(image, exception);
8957
+ GVL_STRUCT_TYPE(magnify) args = { image, exception };
8958
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
8548
8959
  rm_check_exception(exception, new_image, DestroyOnError);
8549
8960
 
8550
8961
  DestroyExceptionInfo(exception);
@@ -8571,7 +8982,7 @@ VALUE
8571
8982
  Image_magnify(VALUE self)
8572
8983
  {
8573
8984
  rm_check_destroyed(self);
8574
- return magnify(False, self, MagnifyImage);
8985
+ return magnify(False, self, GVL_FUNC(MagnifyImage));
8575
8986
  }
8576
8987
 
8577
8988
 
@@ -8586,7 +8997,7 @@ VALUE
8586
8997
  Image_magnify_bang(VALUE self)
8587
8998
  {
8588
8999
  rm_check_frozen(self);
8589
- return magnify(True, self, MagnifyImage);
9000
+ return magnify(True, self, GVL_FUNC(MagnifyImage));
8590
9001
  }
8591
9002
 
8592
9003
 
@@ -8618,7 +9029,8 @@ Image_marshal_dump(VALUE self)
8618
9029
  rb_ary_store(ary, 0, rb_str_new2(image->filename));
8619
9030
 
8620
9031
  exception = AcquireExceptionInfo();
8621
- blob = ImageToBlob(info, image, &length, exception);
9032
+ GVL_STRUCT_TYPE(ImageToBlob) args = { info, image, &length, exception };
9033
+ blob = (unsigned char *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImageToBlob), &args);
8622
9034
 
8623
9035
  // Destroy info before raising an exception
8624
9036
  DestroyImageInfo(info);
@@ -8663,7 +9075,8 @@ Image_marshal_load(VALUE self, VALUE ary)
8663
9075
  {
8664
9076
  strlcpy(info->filename, RSTRING_PTR(filename), sizeof(info->filename));
8665
9077
  }
8666
- image = BlobToImage(info, RSTRING_PTR(blob), RSTRING_LEN(blob), exception);
9078
+ GVL_STRUCT_TYPE(BlobToImage) args = { info, RSTRING_PTR(blob), RSTRING_LEN(blob), exception };
9079
+ image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args);
8667
9080
 
8668
9081
  // Destroy info before raising an exception
8669
9082
  DestroyImageInfo(info);
@@ -8696,9 +9109,11 @@ get_image_mask(Image *image)
8696
9109
 
8697
9110
  // The returned clip mask is a clone, ours to keep.
8698
9111
  #if defined(IMAGEMAGICK_7)
8699
- mask = GetImageMask(image, WritePixelMask, exception);
9112
+ GVL_STRUCT_TYPE(GetImageMask) args = { image, WritePixelMask, exception };
9113
+ mask = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageMask), &args);
8700
9114
  #else
8701
- mask = GetImageClipMask(image, exception);
9115
+ GVL_STRUCT_TYPE(GetImageClipMask) args = { image, exception };
9116
+ mask = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageClipMask), &args);
8702
9117
  #endif
8703
9118
  rm_check_exception(exception, mask, DestroyOnError);
8704
9119
 
@@ -8736,19 +9151,22 @@ set_image_mask(Image *image, VALUE mask)
8736
9151
  // Resize if necessary
8737
9152
  if (clip_mask->columns != image->columns || clip_mask->rows != image->rows)
8738
9153
  {
8739
- resized_image = ResizeImage(clip_mask, image->columns, image->rows, image->filter, exception);
9154
+ GVL_STRUCT_TYPE(ResizeImage) args = { clip_mask, image->columns, image->rows, image->filter, exception };
9155
+ resized_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ResizeImage), &args);
8740
9156
  DestroyImage(clip_mask);
8741
9157
  rm_check_exception(exception, resized_image, DestroyOnError);
8742
9158
  rm_ensure_result(resized_image);
8743
9159
  clip_mask = resized_image;
8744
9160
  }
8745
9161
 
8746
- SetImageMask(image, WritePixelMask, clip_mask, exception);
9162
+ GVL_STRUCT_TYPE(SetImageMask) args = { image, WritePixelMask, clip_mask, exception };
9163
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args);
8747
9164
  DestroyImage(clip_mask);
8748
9165
  }
8749
9166
  else
8750
9167
  {
8751
- SetImageMask(image, WritePixelMask, NULL, exception);
9168
+ GVL_STRUCT_TYPE(SetImageMask) args = { image, WritePixelMask, NULL, exception };
9169
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args);
8752
9170
  }
8753
9171
  CHECK_EXCEPTION();
8754
9172
  DestroyExceptionInfo(exception);
@@ -8776,8 +9194,8 @@ set_image_mask(Image *image, VALUE mask)
8776
9194
  if (clip_mask->columns != image->columns || clip_mask->rows != image->rows)
8777
9195
  {
8778
9196
  exception = AcquireExceptionInfo();
8779
- resized_image = ResizeImage(clip_mask, image->columns, image->rows,
8780
- UndefinedFilter, 0.0, exception);
9197
+ GVL_STRUCT_TYPE(ResizeImage) args = { clip_mask, image->columns, image->rows, UndefinedFilter, 0.0, exception };
9198
+ resized_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ResizeImage), &args);
8781
9199
  rm_check_exception(exception, resized_image, DestroyOnError);
8782
9200
  DestroyExceptionInfo(exception);
8783
9201
  rm_ensure_result(resized_image);
@@ -8790,7 +9208,8 @@ set_image_mask(Image *image, VALUE mask)
8790
9208
 
8791
9209
  for (y = 0; y < (long) clip_mask->rows; y++)
8792
9210
  {
8793
- q = GetAuthenticPixels(clip_mask, 0, y, clip_mask->columns, 1, exception);
9211
+ GVL_STRUCT_TYPE(GetAuthenticPixels) args_GetAuthenticPixels = { clip_mask, 0, y, clip_mask->columns, 1, exception };
9212
+ q = (PixelPacket *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args_GetAuthenticPixels);
8794
9213
  rm_check_exception(exception, clip_mask, DestroyOnError);
8795
9214
 
8796
9215
  if (!q)
@@ -8809,12 +9228,14 @@ set_image_mask(Image *image, VALUE mask)
8809
9228
  q += 1;
8810
9229
  }
8811
9230
 
8812
- SyncAuthenticPixels(clip_mask, exception);
9231
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args_SyncAuthenticPixels = { clip_mask, exception };
9232
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args_SyncAuthenticPixels);
8813
9233
  rm_check_exception(exception, clip_mask, DestroyOnError);
8814
9234
  }
8815
9235
  DestroyExceptionInfo(exception);
8816
9236
 
8817
- SetImageStorageClass(clip_mask, DirectClass);
9237
+ GVL_STRUCT_TYPE(SetImageStorageClass) args_SetImageStorageClass = { clip_mask, DirectClass };
9238
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args_SetImageStorageClass);
8818
9239
  rm_check_image_exception(clip_mask, DestroyOnError);
8819
9240
 
8820
9241
  clip_mask->matte = MagickTrue;
@@ -8822,12 +9243,14 @@ set_image_mask(Image *image, VALUE mask)
8822
9243
  // SetImageClipMask clones the clip_mask image. We can
8823
9244
  // destroy our copy after SetImageClipMask is done with it.
8824
9245
 
8825
- SetImageClipMask(image, clip_mask);
9246
+ GVL_STRUCT_TYPE(SetImageClipMask) args_SetImageClipMask = { image, clip_mask };
9247
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageClipMask), &args_SetImageClipMask);
8826
9248
  DestroyImage(clip_mask);
8827
9249
  }
8828
9250
  else
8829
9251
  {
8830
- SetImageClipMask(image, NULL);
9252
+ GVL_STRUCT_TYPE(SetImageClipMask) args_SetImageClipMask = { image, NULL };
9253
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageClipMask), &args_SetImageClipMask);
8831
9254
  }
8832
9255
 
8833
9256
  RB_GC_GUARD(mask);
@@ -8968,7 +9391,7 @@ Image_matte_flood_fill(int argc, VALUE *argv, VALUE self)
8968
9391
  rb_raise(rb_eNoMemError, "not enough memory to continue");
8969
9392
  }
8970
9393
  #if defined(IMAGEMAGICK_7)
8971
- draw_info->fill.alpha = alpha;
9394
+ rm_set_pixelinfo_alpha(&draw_info->fill, alpha);
8972
9395
  #else
8973
9396
  draw_info->fill.opacity = QuantumRange - alpha;
8974
9397
  #endif
@@ -8979,6 +9402,11 @@ Image_matte_flood_fill(int argc, VALUE *argv, VALUE self)
8979
9402
  target_mpp.red = (MagickRealType) image->border_color.red;
8980
9403
  target_mpp.green = (MagickRealType) image->border_color.green;
8981
9404
  target_mpp.blue = (MagickRealType) image->border_color.blue;
9405
+ #if defined(IMAGEMAGICK_7)
9406
+ rm_set_pixelinfo_alpha(&target_mpp, (MagickRealType) image->border_color.alpha);
9407
+ #else
9408
+ target_mpp.opacity = (MagickRealType) image->border_color.opacity;
9409
+ #endif
8982
9410
  }
8983
9411
  else
8984
9412
  {
@@ -8986,18 +9414,25 @@ Image_matte_flood_fill(int argc, VALUE *argv, VALUE self)
8986
9414
  target_mpp.red = (MagickRealType) target.red;
8987
9415
  target_mpp.green = (MagickRealType) target.green;
8988
9416
  target_mpp.blue = (MagickRealType) target.blue;
9417
+ #if defined(IMAGEMAGICK_7)
9418
+ rm_set_pixelinfo_alpha(&target_mpp, (MagickRealType) target.alpha);
9419
+ #else
9420
+ target_mpp.opacity = (MagickRealType) target.opacity;
9421
+ #endif
8989
9422
  }
8990
9423
 
8991
9424
  #if defined(IMAGEMAGICK_7)
8992
9425
  exception = AcquireExceptionInfo();
8993
9426
  BEGIN_CHANNEL_MASK(new_image, OpacityChannel);
8994
- FloodfillPaintImage(new_image, draw_info, &target_mpp, x, y, invert, exception);
9427
+ GVL_STRUCT_TYPE(FloodfillPaintImage) args = { new_image, draw_info, &target_mpp, x, y, invert, exception };
9428
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FloodfillPaintImage), &args);
8995
9429
  END_CHANNEL_MASK(new_image);
8996
9430
  DestroyDrawInfo(draw_info);
8997
9431
  rm_check_exception(exception, new_image, DestroyOnError);
8998
9432
  DestroyExceptionInfo(exception);
8999
9433
  #else
9000
- FloodfillPaintImage(new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert);
9434
+ GVL_STRUCT_TYPE(FloodfillPaintImage) args = { new_image, OpacityChannel, draw_info, &target_mpp, x, y, invert };
9435
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FloodfillPaintImage), &args);
9001
9436
  DestroyDrawInfo(draw_info);
9002
9437
 
9003
9438
  rm_check_image_exception(new_image, DestroyOnError);
@@ -9035,7 +9470,8 @@ Image_median_filter(int argc, VALUE *argv, VALUE self)
9035
9470
  }
9036
9471
 
9037
9472
  exception = AcquireExceptionInfo();
9038
- new_image = StatisticImage(image, MedianStatistic, (size_t)radius, (size_t)radius, exception);
9473
+ GVL_STRUCT_TYPE(StatisticImage) args = { image, MedianStatistic, (size_t)radius, (size_t)radius, exception };
9474
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(StatisticImage), &args);
9039
9475
  rm_check_exception(exception, new_image, DestroyOnError);
9040
9476
  DestroyExceptionInfo(exception);
9041
9477
 
@@ -9051,7 +9487,7 @@ Image_median_filter(int argc, VALUE *argv, VALUE self)
9051
9487
  VALUE
9052
9488
  Image_mean_error_per_pixel(VALUE self)
9053
9489
  {
9054
- IMPLEMENT_ATTR_READERF(Image, mean_error_per_pixel, error.mean_error_per_pixel, dbl);
9490
+ IMPLEMENT_TYPED_ATTR_READERF(Image, mean_error_per_pixel, error.mean_error_per_pixel, dbl, &rm_image_data_type);
9055
9491
  }
9056
9492
 
9057
9493
 
@@ -9094,7 +9530,7 @@ VALUE
9094
9530
  Image_minify(VALUE self)
9095
9531
  {
9096
9532
  rm_check_destroyed(self);
9097
- return magnify(False, self, MinifyImage);
9533
+ return magnify(False, self, GVL_FUNC(MinifyImage));
9098
9534
  }
9099
9535
 
9100
9536
 
@@ -9108,7 +9544,7 @@ VALUE
9108
9544
  Image_minify_bang(VALUE self)
9109
9545
  {
9110
9546
  rm_check_frozen(self);
9111
- return magnify(True, self, MinifyImage);
9547
+ return magnify(True, self, GVL_FUNC(MinifyImage));
9112
9548
  }
9113
9549
 
9114
9550
 
@@ -9160,11 +9596,13 @@ Image_modulate(int argc, VALUE *argv, VALUE self)
9160
9596
 
9161
9597
  #if defined(IMAGEMAGICK_7)
9162
9598
  exception = AcquireExceptionInfo();
9163
- ModulateImage(new_image, modulate, exception);
9599
+ GVL_STRUCT_TYPE(ModulateImage) args = { new_image, modulate, exception };
9600
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ModulateImage), &args);
9164
9601
  rm_check_exception(exception, new_image, DestroyOnError);
9165
9602
  DestroyExceptionInfo(exception);
9166
9603
  #else
9167
- ModulateImage(new_image, modulate);
9604
+ GVL_STRUCT_TYPE(ModulateImage) args = { new_image, modulate };
9605
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ModulateImage), &args);
9168
9606
  rm_check_image_exception(new_image, DestroyOnError);
9169
9607
  #endif
9170
9608
 
@@ -9172,39 +9610,6 @@ Image_modulate(int argc, VALUE *argv, VALUE self)
9172
9610
  }
9173
9611
 
9174
9612
 
9175
- /**
9176
- * Establish a progress monitor.
9177
- *
9178
- * - A progress monitor is a callable object. Save the monitor proc as the client_data and establish
9179
- * `progress_monitor' as the monitor exit. When `progress_monitor' is called, retrieve the proc
9180
- * and call it.
9181
- *
9182
- * @param monitor [Proc] the progress monitor
9183
- * @return [Proc] the given value
9184
- * @example
9185
- * img.monitor = Proc.new do |method, offset, span|
9186
- * print "%s is %3.0f%% complete.\n", method, (offset.to_f/span)*100)
9187
- * true
9188
- * end
9189
- */
9190
- VALUE
9191
- Image_monitor_eq(VALUE self, VALUE monitor)
9192
- {
9193
- Image *image = rm_check_frozen(self);
9194
-
9195
- if (NIL_P(monitor))
9196
- {
9197
- image->progress_monitor = NULL;
9198
- }
9199
- else
9200
- {
9201
- SetImageProgressMonitor(image, rm_progress_monitor, (void *)monitor);
9202
- }
9203
-
9204
- return monitor;
9205
- }
9206
-
9207
-
9208
9613
  /**
9209
9614
  * Return true if all the pixels in the image have the same red, green, and blue intensities and the
9210
9615
  * intensity is either 0 or {Magick::QuantumRange}.
@@ -9230,10 +9635,13 @@ Image_monochrome_q(VALUE self)
9230
9635
  VALUE
9231
9636
  Image_montage(VALUE self)
9232
9637
  {
9233
- IMPLEMENT_ATTR_READER(Image, montage, str);
9638
+ IMPLEMENT_TYPED_ATTR_READER(Image, montage, str, &rm_image_data_type);
9234
9639
  }
9235
9640
 
9236
9641
 
9642
+ // aliases for common use of structure types; MotionBlurImage, SketchImage
9643
+ typedef GVL_STRUCT_TYPE(MotionBlurImage) GVL_STRUCT_TYPE(motion_blur);
9644
+
9237
9645
  /**
9238
9646
  * Called from Image_motion_blur and Image_sketch.
9239
9647
  *
@@ -9248,8 +9656,7 @@ Image_montage(VALUE self)
9248
9656
  * @see Image_sketch
9249
9657
  */
9250
9658
  static VALUE
9251
- motion_blur(int argc, VALUE *argv, VALUE self,
9252
- Image *fp(const Image *, const double, const double, const double, ExceptionInfo *))
9659
+ motion_blur(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
9253
9660
  {
9254
9661
  Image *image, *new_image;
9255
9662
  double radius = 0.0;
@@ -9277,10 +9684,11 @@ motion_blur(int argc, VALUE *argv, VALUE self,
9277
9684
  rb_raise(rb_eArgError, "sigma must be != 0.0");
9278
9685
  }
9279
9686
 
9280
- Data_Get_Struct(self, Image, image);
9687
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
9281
9688
 
9282
9689
  exception = AcquireExceptionInfo();
9283
- new_image = (fp)(image, radius, sigma, angle, exception);
9690
+ GVL_STRUCT_TYPE(motion_blur) args = { image, radius, sigma, angle, exception };
9691
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
9284
9692
  rm_check_exception(exception, new_image, DestroyOnError);
9285
9693
  DestroyExceptionInfo(exception);
9286
9694
 
@@ -9304,7 +9712,7 @@ VALUE
9304
9712
  Image_motion_blur(int argc, VALUE *argv, VALUE self)
9305
9713
  {
9306
9714
  rm_check_destroyed(self);
9307
- return motion_blur(argc, argv, self, MotionBlurImage);
9715
+ return motion_blur(argc, argv, self, GVL_FUNC(MotionBlurImage));
9308
9716
  }
9309
9717
 
9310
9718
 
@@ -9339,11 +9747,13 @@ Image_negate(int argc, VALUE *argv, VALUE self)
9339
9747
 
9340
9748
  #if defined(IMAGEMAGICK_7)
9341
9749
  exception = AcquireExceptionInfo();
9342
- NegateImage(new_image, grayscale, exception);
9750
+ GVL_STRUCT_TYPE(NegateImage) args = { new_image, grayscale, exception };
9751
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args);
9343
9752
  rm_check_exception(exception, new_image, DestroyOnError);
9344
9753
  DestroyExceptionInfo(exception);
9345
9754
  #else
9346
- NegateImage(new_image, grayscale);
9755
+ GVL_STRUCT_TYPE(NegateImage) args = { new_image, grayscale };
9756
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args);
9347
9757
  rm_check_image_exception(new_image, DestroyOnError);
9348
9758
  #endif
9349
9759
 
@@ -9396,12 +9806,14 @@ Image_negate_channel(int argc, VALUE *argv, VALUE self)
9396
9806
  #if defined(IMAGEMAGICK_7)
9397
9807
  exception = AcquireExceptionInfo();
9398
9808
  BEGIN_CHANNEL_MASK(new_image, channels);
9399
- NegateImage(new_image, grayscale, exception);
9809
+ GVL_STRUCT_TYPE(NegateImage) args = { new_image, grayscale, exception };
9810
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args);
9400
9811
  END_CHANNEL_MASK(new_image);
9401
9812
  rm_check_exception(exception, new_image, DestroyOnError);
9402
9813
  DestroyExceptionInfo(exception);
9403
9814
  #else
9404
- NegateImageChannel(new_image, channels, grayscale);
9815
+ GVL_STRUCT_TYPE(NegateImageChannel) args = { new_image, channels, grayscale };
9816
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImageChannel), &args);
9405
9817
  rm_check_image_exception(new_image, DestroyOnError);
9406
9818
  #endif
9407
9819
 
@@ -9419,7 +9831,7 @@ Image_alloc(VALUE class)
9419
9831
  {
9420
9832
  VALUE image_obj;
9421
9833
 
9422
- image_obj = Data_Wrap_Struct(class, NULL, rm_image_destroy, NULL);
9834
+ image_obj = TypedData_Wrap_Struct(class, &rm_image_data_type, NULL);
9423
9835
 
9424
9836
  RB_GC_GUARD(image_obj);
9425
9837
 
@@ -9463,7 +9875,7 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9463
9875
 
9464
9876
  // Create a new Info object to use when creating this image.
9465
9877
  info_obj = rm_info_new();
9466
- Data_Get_Struct(info_obj, Info, info);
9878
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
9467
9879
 
9468
9880
  image = rm_acquire_image(info);
9469
9881
  if (!image)
@@ -9478,11 +9890,13 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9478
9890
 
9479
9891
  #if defined(IMAGEMAGICK_7)
9480
9892
  exception = AcquireExceptionInfo();
9481
- SetImageExtent(image, cols, rows, exception);
9893
+ GVL_STRUCT_TYPE(SetImageExtent) args = { image, cols, rows, exception };
9894
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageExtent), &args);
9482
9895
  CHECK_EXCEPTION();
9483
9896
  DestroyExceptionInfo(exception);
9484
9897
  #else
9485
- SetImageExtent(image, cols, rows);
9898
+ GVL_STRUCT_TYPE(SetImageExtent) args = { image, cols, rows };
9899
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageExtent), &args);
9486
9900
  #endif
9487
9901
 
9488
9902
  // If the caller did not supply a fill argument, call SetImageBackgroundColor
@@ -9492,11 +9906,13 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9492
9906
  {
9493
9907
  #if defined(IMAGEMAGICK_7)
9494
9908
  exception = AcquireExceptionInfo();
9495
- SetImageBackgroundColor(image, exception);
9909
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image, exception };
9910
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
9496
9911
  CHECK_EXCEPTION();
9497
9912
  DestroyExceptionInfo(exception);
9498
9913
  #else
9499
- SetImageBackgroundColor(image);
9914
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image };
9915
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
9500
9916
  #endif
9501
9917
  }
9502
9918
  // fillobj.fill(self)
@@ -9529,9 +9945,7 @@ rm_image_new(Image *image)
9529
9945
  {
9530
9946
  rm_ensure_result(image);
9531
9947
 
9532
- rm_trace_creation(image);
9533
-
9534
- return Data_Wrap_Struct(Class_Image, NULL, rm_image_destroy, image);
9948
+ return TypedData_Wrap_Struct(Class_Image, &rm_image_data_type, image);
9535
9949
  }
9536
9950
 
9537
9951
 
@@ -9554,11 +9968,13 @@ Image_normalize(VALUE self)
9554
9968
 
9555
9969
  #if defined(IMAGEMAGICK_7)
9556
9970
  exception = AcquireExceptionInfo();
9557
- NormalizeImage(new_image, exception);
9971
+ GVL_STRUCT_TYPE(NormalizeImage) args = { new_image, exception };
9972
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImage), &args);
9558
9973
  rm_check_exception(exception, new_image, DestroyOnError);
9559
9974
  DestroyExceptionInfo(exception);
9560
9975
  #else
9561
- NormalizeImage(new_image);
9976
+ GVL_STRUCT_TYPE(NormalizeImage) args = { new_image };
9977
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImage), &args);
9562
9978
  rm_check_image_exception(new_image, DestroyOnError);
9563
9979
  #endif
9564
9980
 
@@ -9596,12 +10012,14 @@ Image_normalize_channel(int argc, VALUE *argv, VALUE self)
9596
10012
  #if defined(IMAGEMAGICK_7)
9597
10013
  exception = AcquireExceptionInfo();
9598
10014
  BEGIN_CHANNEL_MASK(new_image, channels);
9599
- NormalizeImage(new_image, exception);
10015
+ GVL_STRUCT_TYPE(NormalizeImage) args = { new_image, exception };
10016
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImage), &args);
9600
10017
  END_CHANNEL_MASK(new_image);
9601
10018
  rm_check_exception(exception, new_image, DestroyOnError);
9602
10019
  DestroyExceptionInfo(exception);
9603
10020
  #else
9604
- NormalizeImageChannel(new_image, channels);
10021
+ GVL_STRUCT_TYPE(NormalizeImageChannel) args = { new_image, channels };
10022
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImageChannel), &args);
9605
10023
  rm_check_image_exception(new_image, DestroyOnError);
9606
10024
  #endif
9607
10025
 
@@ -9617,7 +10035,7 @@ Image_normalize_channel(int argc, VALUE *argv, VALUE self)
9617
10035
  VALUE
9618
10036
  Image_normalized_mean_error(VALUE self)
9619
10037
  {
9620
- IMPLEMENT_ATTR_READERF(Image, normalized_mean_error, error.normalized_mean_error, dbl);
10038
+ IMPLEMENT_TYPED_ATTR_READERF(Image, normalized_mean_error, error.normalized_mean_error, dbl, &rm_image_data_type);
9621
10039
  }
9622
10040
 
9623
10041
  /**
@@ -9628,7 +10046,7 @@ Image_normalized_mean_error(VALUE self)
9628
10046
  VALUE
9629
10047
  Image_normalized_maximum_error(VALUE self)
9630
10048
  {
9631
- IMPLEMENT_ATTR_READERF(Image, normalized_maximum_error, error.normalized_maximum_error, dbl);
10049
+ IMPLEMENT_TYPED_ATTR_READERF(Image, normalized_maximum_error, error.normalized_maximum_error, dbl, &rm_image_data_type);
9632
10050
  }
9633
10051
 
9634
10052
 
@@ -9642,12 +10060,13 @@ Image_number_colors(VALUE self)
9642
10060
  {
9643
10061
  Image *image;
9644
10062
  ExceptionInfo *exception;
9645
- unsigned long n = 0;
10063
+ size_t n = 0;
9646
10064
 
9647
10065
  image = rm_check_destroyed(self);
9648
10066
  exception = AcquireExceptionInfo();
9649
10067
 
9650
- n = (unsigned long) GetNumberColors(image, NULL, exception);
10068
+ GVL_STRUCT_TYPE(GetNumberColors) args = { image, NULL, exception };
10069
+ n = (size_t)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetNumberColors), &args);
9651
10070
  CHECK_EXCEPTION();
9652
10071
 
9653
10072
  DestroyExceptionInfo(exception);
@@ -9664,7 +10083,7 @@ Image_number_colors(VALUE self)
9664
10083
  VALUE
9665
10084
  Image_offset(VALUE self)
9666
10085
  {
9667
- IMPLEMENT_ATTR_READER(Image, offset, long);
10086
+ IMPLEMENT_TYPED_ATTR_READER(Image, offset, long, &rm_image_data_type);
9668
10087
  }
9669
10088
 
9670
10089
  /**
@@ -9676,7 +10095,7 @@ Image_offset(VALUE self)
9676
10095
  VALUE
9677
10096
  Image_offset_eq(VALUE self, VALUE val)
9678
10097
  {
9679
- IMPLEMENT_ATTR_WRITER(Image, offset, long);
10098
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, offset, long, &rm_image_data_type);
9680
10099
  }
9681
10100
 
9682
10101
 
@@ -9712,10 +10131,11 @@ Image_oil_paint(int argc, VALUE *argv, VALUE self)
9712
10131
  exception = AcquireExceptionInfo();
9713
10132
 
9714
10133
  #if defined(IMAGEMAGICK_7)
9715
- new_image = OilPaintImage(image, radius, sigma, exception);
10134
+ GVL_STRUCT_TYPE(OilPaintImage) args = { image, radius, sigma, exception };
9716
10135
  #else
9717
- new_image = OilPaintImage(image, radius, exception);
10136
+ GVL_STRUCT_TYPE(OilPaintImage) args = { image, radius, exception };
9718
10137
  #endif
10138
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OilPaintImage), &args);
9719
10139
  rm_check_exception(exception, new_image, DestroyOnError);
9720
10140
  DestroyExceptionInfo(exception);
9721
10141
 
@@ -9756,11 +10176,13 @@ Image_opaque(VALUE self, VALUE target, VALUE fill)
9756
10176
 
9757
10177
  #if defined(IMAGEMAGICK_7)
9758
10178
  exception = AcquireExceptionInfo();
9759
- okay = OpaquePaintImage(new_image, &target_pp, &fill_pp, MagickFalse, exception);
10179
+ GVL_STRUCT_TYPE(OpaquePaintImage) args = { new_image, &target_pp, &fill_pp, MagickFalse, exception };
10180
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
9760
10181
  rm_check_exception(exception, new_image, DestroyOnError);
9761
10182
  DestroyExceptionInfo(exception);
9762
10183
  #else
9763
- okay = OpaquePaintImageChannel(new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse);
10184
+ GVL_STRUCT_TYPE(OpaquePaintImageChannel) args = { new_image, DefaultChannels, &target_pp, &fill_pp, MagickFalse };
10185
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
9764
10186
  rm_check_image_exception(new_image, DestroyOnError);
9765
10187
  #endif
9766
10188
 
@@ -9846,13 +10268,15 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
9846
10268
  #if defined(IMAGEMAGICK_7)
9847
10269
  exception = AcquireExceptionInfo();
9848
10270
  BEGIN_CHANNEL_MASK(new_image, channels);
9849
- okay = OpaquePaintImage(new_image, &target_pp, &fill_pp, invert, exception);
10271
+ GVL_STRUCT_TYPE(OpaquePaintImage) args = { new_image, &target_pp, &fill_pp, invert, exception };
10272
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImage), &args);
9850
10273
  END_CHANNEL_MASK(new_image);
9851
10274
  new_image->fuzz = keep;
9852
10275
  rm_check_exception(exception, new_image, DestroyOnError);
9853
10276
  DestroyExceptionInfo(exception);
9854
10277
  #else
9855
- okay = OpaquePaintImageChannel(new_image, channels, &target_pp, &fill_pp, invert);
10278
+ GVL_STRUCT_TYPE(OpaquePaintImageChannel) args = { new_image, channels, &target_pp, &fill_pp, invert };
10279
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OpaquePaintImageChannel), &args);
9856
10280
 
9857
10281
  new_image->fuzz = keep;
9858
10282
  rm_check_image_exception(new_image, DestroyOnError);
@@ -9937,7 +10361,13 @@ Image_ordered_dither(int argc, VALUE *argv, VALUE self)
9937
10361
 
9938
10362
  exception = AcquireExceptionInfo();
9939
10363
 
9940
- OrderedDitherImage(new_image, threshold_map, exception);
10364
+ #if defined(IMAGEMAGICK_7)
10365
+ GVL_STRUCT_TYPE(OrderedDitherImage) args = { new_image, threshold_map, exception };
10366
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OrderedDitherImage), &args);
10367
+ #else
10368
+ GVL_STRUCT_TYPE(OrderedPosterizeImage) args = { new_image, threshold_map, exception };
10369
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OrderedPosterizeImage), &args);
10370
+ #endif
9941
10371
  rm_check_exception(exception, new_image, DestroyOnError);
9942
10372
 
9943
10373
  DestroyExceptionInfo(exception);
@@ -10072,12 +10502,14 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
10072
10502
 
10073
10503
  #if defined(IMAGEMAGICK_7)
10074
10504
  exception = AcquireExceptionInfo();
10075
- okay = TransparentPaintImage(new_image, (const MagickPixel *)&color, alpha, invert, exception);
10505
+ GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, alpha, invert, exception };
10506
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
10076
10507
  new_image->fuzz = keep;
10077
10508
  rm_check_exception(exception, new_image, DestroyOnError);
10078
10509
  DestroyExceptionInfo(exception);
10079
10510
  #else
10080
- okay = TransparentPaintImage(new_image, (const MagickPixel *)&color, QuantumRange - alpha, invert);
10511
+ GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, (const MagickPixel *)&color, QuantumRange - alpha, invert };
10512
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
10081
10513
  new_image->fuzz = keep;
10082
10514
 
10083
10515
  // Is it possible for TransparentPaintImage to silently fail?
@@ -10120,7 +10552,7 @@ Image_palette_q(VALUE self)
10120
10552
  VALUE
10121
10553
  Image_ping(VALUE class, VALUE file_arg)
10122
10554
  {
10123
- return rd_image(class, file_arg, PingImage);
10555
+ return rd_image(class, file_arg, GVL_FUNC(PingImage));
10124
10556
  }
10125
10557
 
10126
10558
 
@@ -10186,7 +10618,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10186
10618
  if (!set)
10187
10619
  {
10188
10620
  exception = AcquireExceptionInfo();
10189
- old_pixel = GetVirtualPixels(image, x, y, 1, 1, exception);
10621
+ GVL_STRUCT_TYPE(GetVirtualPixels) args = { image, x, y, 1, 1, exception };
10622
+ old_pixel = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args);
10190
10623
  CHECK_EXCEPTION();
10191
10624
 
10192
10625
  DestroyExceptionInfo(exception);
@@ -10238,7 +10671,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10238
10671
  if (image->storage_class == PseudoClass)
10239
10672
  {
10240
10673
  #if defined(IMAGEMAGICK_7)
10241
- okay = SetImageStorageClass(image, DirectClass, exception);
10674
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass, exception };
10675
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10242
10676
  CHECK_EXCEPTION();
10243
10677
  if (!okay)
10244
10678
  {
@@ -10246,7 +10680,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10246
10680
  rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't set pixel color.");
10247
10681
  }
10248
10682
  #else
10249
- okay = SetImageStorageClass(image, DirectClass);
10683
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
10684
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10250
10685
  rm_check_image_exception(image, RetainOnError);
10251
10686
  if (!okay)
10252
10687
  {
@@ -10259,7 +10694,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10259
10694
  exception = AcquireExceptionInfo();
10260
10695
  #endif
10261
10696
 
10262
- pixel = GetAuthenticPixels(image, x, y, 1, 1, exception);
10697
+ GVL_STRUCT_TYPE(GetAuthenticPixels) args = { image, x, y, 1, 1, exception };
10698
+ pixel = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args);
10263
10699
  CHECK_EXCEPTION();
10264
10700
 
10265
10701
  if (pixel)
@@ -10294,7 +10730,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10294
10730
  }
10295
10731
  #endif
10296
10732
 
10297
- SyncAuthenticPixels(image, exception);
10733
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
10734
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
10298
10735
  CHECK_EXCEPTION();
10299
10736
  }
10300
10737
 
@@ -10349,11 +10786,11 @@ Image_pixel_interpolation_method_eq(VALUE self, VALUE method)
10349
10786
  * If present a block, optional arguments may be specified in a block associated with the method.
10350
10787
  * These arguments control the shadow color and how the label is rendered.
10351
10788
  * By default the shadow color is gray75. To specify a different shadow color,
10352
- * use self.shadow_color.
10353
- * To specify a different border color (that is, the color of the image border) use self.border_color.
10789
+ * use options.shadow_color.
10790
+ * To specify a different border color (that is, the color of the image border) use options.border_color.
10354
10791
  * Both of these methods accept either a color name or a Pixel argument.
10355
10792
  * @param angle [Float] The resulting image is rotated by this amount, measured in degrees.
10356
- * @yield []
10793
+ * @yield [Magick::Image::Info]
10357
10794
  *
10358
10795
  * @return [Magick::Image] a new image
10359
10796
  */
@@ -10383,7 +10820,7 @@ Image_polaroid(int argc, VALUE *argv, VALUE self)
10383
10820
  }
10384
10821
 
10385
10822
  options = rm_polaroid_new();
10386
- Data_Get_Struct(options, Draw, draw);
10823
+ TypedData_Get_Struct(options, Draw, &rm_draw_data_type, draw);
10387
10824
 
10388
10825
  clone = rm_clone_image(image);
10389
10826
  clone->background_color = draw->shadow_color;
@@ -10392,9 +10829,11 @@ Image_polaroid(int argc, VALUE *argv, VALUE self)
10392
10829
  exception = AcquireExceptionInfo();
10393
10830
  #if defined(IMAGEMAGICK_7)
10394
10831
  caption = GetImageProperty(clone, "Caption", exception);
10395
- new_image = PolaroidImage(clone, draw->info, caption, angle, image->interpolate, exception);
10832
+ GVL_STRUCT_TYPE(PolaroidImage) args = { clone, draw->info, caption, angle, image->interpolate, exception };
10833
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PolaroidImage), &args);
10396
10834
  #else
10397
- new_image = PolaroidImage(clone, draw->info, angle, exception);
10835
+ GVL_STRUCT_TYPE(PolaroidImage) args = { clone, draw->info, angle, exception };
10836
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PolaroidImage), &args);
10398
10837
  #endif
10399
10838
  rm_check_exception(exception, clone, DestroyOnError);
10400
10839
 
@@ -10446,11 +10885,13 @@ Image_posterize(int argc, VALUE *argv, VALUE self)
10446
10885
  #if defined(IMAGEMAGICK_7)
10447
10886
  exception = AcquireExceptionInfo();
10448
10887
  dither_method = dither ? RiemersmaDitherMethod : NoDitherMethod;
10449
- PosterizeImage(new_image, levels, dither_method, exception);
10888
+ GVL_STRUCT_TYPE(PosterizeImage) args = { new_image, levels, dither_method, exception };
10889
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PosterizeImage), &args);
10450
10890
  rm_check_exception(exception, new_image, DestroyOnError);
10451
10891
  DestroyExceptionInfo(exception);
10452
10892
  #else
10453
- PosterizeImage(new_image, levels, dither);
10893
+ GVL_STRUCT_TYPE(PosterizeImage) args = { new_image, levels, dither };
10894
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PosterizeImage), &args);
10454
10895
  rm_check_image_exception(new_image, DestroyOnError);
10455
10896
  #endif
10456
10897
 
@@ -10476,7 +10917,8 @@ Image_preview(VALUE self, VALUE preview)
10476
10917
  VALUE_TO_ENUM(preview, preview_type, PreviewType);
10477
10918
 
10478
10919
  exception = AcquireExceptionInfo();
10479
- new_image = PreviewImage(image, preview_type, exception);
10920
+ GVL_STRUCT_TYPE(PreviewImage) args = { image, preview_type, exception };
10921
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PreviewImage), &args);
10480
10922
  rm_check_exception(exception, new_image, DestroyOnError);
10481
10923
 
10482
10924
  DestroyExceptionInfo(exception);
@@ -10517,7 +10959,7 @@ Image_profile_bang(VALUE self, VALUE name, VALUE profile)
10517
10959
  VALUE
10518
10960
  Image_quality(VALUE self)
10519
10961
  {
10520
- IMPLEMENT_ATTR_READER(Image, quality, ulong);
10962
+ IMPLEMENT_TYPED_ATTR_READER(Image, quality, ulong, &rm_image_data_type);
10521
10963
  }
10522
10964
 
10523
10965
 
@@ -10703,10 +11145,12 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
10703
11145
  exception = AcquireExceptionInfo();
10704
11146
  #if defined(IMAGEMAGICK_7)
10705
11147
  BEGIN_CHANNEL_MASK(image, channel);
10706
- EvaluateImage(image, qop, rvalue, exception);
11148
+ GVL_STRUCT_TYPE(EvaluateImage) args = { image, qop, rvalue, exception };
11149
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EvaluateImage), &args);
10707
11150
  END_CHANNEL_MASK(image);
10708
11151
  #else
10709
- EvaluateImageChannel(image, channel, qop, rvalue, exception);
11152
+ GVL_STRUCT_TYPE(EvaluateImageChannel) args = { image, channel, qop, rvalue, exception };
11153
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EvaluateImageChannel), &args);
10710
11154
  #endif
10711
11155
  CHECK_EXCEPTION();
10712
11156
 
@@ -10783,11 +11227,13 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
10783
11227
 
10784
11228
  #if defined(IMAGEMAGICK_7)
10785
11229
  exception = AcquireExceptionInfo();
10786
- QuantizeImage(&quantize_info, new_image, exception);
11230
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &quantize_info, new_image, exception };
11231
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
10787
11232
  rm_check_exception(exception, new_image, DestroyOnError);
10788
11233
  DestroyExceptionInfo(exception);
10789
11234
  #else
10790
- QuantizeImage(&quantize_info, new_image);
11235
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &quantize_info, new_image };
11236
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
10791
11237
  rm_check_image_exception(new_image, DestroyOnError);
10792
11238
  #endif
10793
11239
 
@@ -10812,9 +11258,11 @@ Image_radial_blur(VALUE self, VALUE angle_obj)
10812
11258
  exception = AcquireExceptionInfo();
10813
11259
 
10814
11260
  #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10815
- new_image = RotationalBlurImage(image, angle, exception);
11261
+ GVL_STRUCT_TYPE(RotationalBlurImage) args = { image, angle, exception };
11262
+ new_image = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RotationalBlurImage), &args);
10816
11263
  #else
10817
- new_image = RadialBlurImage(image, angle, exception);
11264
+ GVL_STRUCT_TYPE(RadialBlurImage) args = { image, angle, exception };
11265
+ new_image = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RadialBlurImage), &args);
10818
11266
  #endif
10819
11267
  rm_check_exception(exception, new_image, DestroyOnError);
10820
11268
  DestroyExceptionInfo(exception);
@@ -10862,13 +11310,16 @@ Image_radial_blur_channel(int argc, VALUE *argv, VALUE self)
10862
11310
 
10863
11311
  #if defined(IMAGEMAGICK_7)
10864
11312
  BEGIN_CHANNEL_MASK(image, channels);
10865
- new_image = RotationalBlurImage(image, angle, exception);
11313
+ GVL_STRUCT_TYPE(RotationalBlurImage) args = { image, angle, exception };
11314
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RotationalBlurImage), &args);
10866
11315
  CHANGE_RESULT_CHANNEL_MASK(new_image);
10867
11316
  END_CHANNEL_MASK(image);
10868
11317
  #elif defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10869
- new_image = RotationalBlurImageChannel(image, channels, angle, exception);
11318
+ GVL_STRUCT_TYPE(RotationalBlurImageChannel) args = { image, channels, angle, exception };
11319
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RotationalBlurImageChannel), &args);
10870
11320
  #else
10871
- new_image = RadialBlurImageChannel(image, channels, angle, exception);
11321
+ GVL_STRUCT_TYPE(RadialBlurImageChannel) args = { image, channels, angle, exception };
11322
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RadialBlurImageChannel), &args);
10872
11323
  #endif
10873
11324
  rm_check_exception(exception, new_image, DestroyOnError);
10874
11325
  DestroyExceptionInfo(exception);
@@ -10929,11 +11380,13 @@ Image_random_threshold_channel(int argc, VALUE *argv, VALUE self)
10929
11380
  GeometryInfo geometry_info;
10930
11381
 
10931
11382
  ParseGeometry(thresholds, &geometry_info);
10932
- RandomThresholdImage(new_image, geometry_info.rho, geometry_info.sigma, exception);
11383
+ GVL_STRUCT_TYPE(RandomThresholdImage) args = { new_image, geometry_info.rho, geometry_info.sigma, exception };
11384
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RandomThresholdImage), &args);
10933
11385
  }
10934
11386
  END_CHANNEL_MASK(new_image);
10935
11387
  #else
10936
- RandomThresholdImageChannel(new_image, channels, thresholds, exception);
11388
+ GVL_STRUCT_TYPE(RandomThresholdImageChannel) args = { new_image, channels, thresholds, exception };
11389
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RandomThresholdImageChannel), &args);
10937
11390
  #endif
10938
11391
  rm_check_exception(exception, new_image, DestroyOnError);
10939
11392
 
@@ -10990,11 +11443,13 @@ Image_raise(int argc, VALUE *argv, VALUE self)
10990
11443
 
10991
11444
  #if defined(IMAGEMAGICK_7)
10992
11445
  exception = AcquireExceptionInfo();
10993
- RaiseImage(new_image, &rect, raised, exception);
11446
+ GVL_STRUCT_TYPE(RaiseImage) args = { new_image, &rect, raised, exception };
11447
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RaiseImage), &args);
10994
11448
  rm_check_exception(exception, new_image, DestroyOnError);
10995
11449
  DestroyExceptionInfo(exception);
10996
11450
  #else
10997
- RaiseImage(new_image, &rect, raised);
11451
+ GVL_STRUCT_TYPE(RaiseImage) args = { new_image, &rect, raised };
11452
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RaiseImage), &args);
10998
11453
  rm_check_image_exception(new_image, DestroyOnError);
10999
11454
  #endif
11000
11455
 
@@ -11011,7 +11466,7 @@ Image_raise(int argc, VALUE *argv, VALUE self)
11011
11466
  VALUE
11012
11467
  Image_read(VALUE class, VALUE file_arg)
11013
11468
  {
11014
- return rd_image(class, file_arg, ReadImage);
11469
+ return rd_image(class, file_arg, GVL_FUNC(ReadImage));
11015
11470
  }
11016
11471
 
11017
11472
 
@@ -11031,6 +11486,9 @@ file_arg_rescue(VALUE arg, VALUE raised_exc ATTRIBUTE_UNUSED)
11031
11486
  }
11032
11487
 
11033
11488
 
11489
+ // aliases for common use of structure types; PingImage, ReadImage
11490
+ typedef GVL_STRUCT_TYPE(PingImage) GVL_STRUCT_TYPE(rd_image);
11491
+
11034
11492
  /**
11035
11493
  * Transform arguments, call either ReadImage or PingImage.
11036
11494
  *
@@ -11056,7 +11514,7 @@ void sig_handler(int sig ATTRIBUTE_UNUSED)
11056
11514
  #endif
11057
11515
 
11058
11516
  static VALUE
11059
- rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, reader_t reader)
11517
+ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, gvl_function_t fp)
11060
11518
  {
11061
11519
  char *filename;
11062
11520
  long filename_l;
@@ -11067,7 +11525,7 @@ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, reader_t reader)
11067
11525
 
11068
11526
  // Create a new Info structure for this read/ping
11069
11527
  info_obj = rm_info_new();
11070
- Data_Get_Struct(info_obj, Info, info);
11528
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
11071
11529
 
11072
11530
  if (TYPE(file) == T_FILE)
11073
11531
  {
@@ -11107,7 +11565,8 @@ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, reader_t reader)
11107
11565
  }
11108
11566
  #endif
11109
11567
 
11110
- images = (reader)(info, exception);
11568
+ GVL_STRUCT_TYPE(rd_image) args = { info, exception };
11569
+ images = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
11111
11570
 
11112
11571
  #if defined(__APPLE__) || defined(__FreeBSD__)
11113
11572
  if (sigaction(SIGCHLD, &oldact, NULL) < 0)
@@ -11192,7 +11651,8 @@ Image_recolor(VALUE self, VALUE color_matrix)
11192
11651
  kernel_info->height = order;
11193
11652
  kernel_info->values = (double *) matrix;
11194
11653
 
11195
- new_image = ColorMatrixImage(image, kernel_info, exception);
11654
+ GVL_STRUCT_TYPE(ColorMatrixImage) args = { image, kernel_info, exception };
11655
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ColorMatrixImage), &args);
11196
11656
  kernel_info->values = (double *) NULL;
11197
11657
  DestroyKernelInfo(kernel_info);
11198
11658
  xfree((void *) matrix);
@@ -11239,7 +11699,8 @@ Image_read_inline(VALUE self ATTRIBUTE_UNUSED, VALUE content)
11239
11699
  image_data += x + 1;
11240
11700
  }
11241
11701
 
11242
- blob = Base64Decode(image_data, &blob_l);
11702
+ GVL_STRUCT_TYPE(Base64Decode) args_Base64Decode = { image_data, &blob_l };
11703
+ blob = (unsigned char *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(Base64Decode), &args_Base64Decode);
11243
11704
  if (blob_l == 0)
11244
11705
  {
11245
11706
  rb_raise(rb_eArgError, "can't decode image");
@@ -11250,9 +11711,10 @@ Image_read_inline(VALUE self ATTRIBUTE_UNUSED, VALUE content)
11250
11711
  // Create a new Info structure for this read. About the
11251
11712
  // only useful attribute that can be set is `format'.
11252
11713
  info_obj = rm_info_new();
11253
- Data_Get_Struct(info_obj, Info, info);
11714
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
11254
11715
 
11255
- images = BlobToImage(info, blob, blob_l, exception);
11716
+ GVL_STRUCT_TYPE(BlobToImage) args_BlobToImage = { info, blob, blob_l, exception };
11717
+ images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlobToImage), &args_BlobToImage);
11256
11718
  magick_free((void *)blob);
11257
11719
 
11258
11720
  rm_check_exception(exception, images, DestroyOnError);
@@ -11314,7 +11776,8 @@ Image_reduce_noise(VALUE self, VALUE radius)
11314
11776
  image = rm_check_destroyed(self);
11315
11777
 
11316
11778
  exception = AcquireExceptionInfo();
11317
- new_image = StatisticImage(image, NonpeakStatistic, radius_size, radius_size, exception);
11779
+ GVL_STRUCT_TYPE(StatisticImage) args = { image, NonpeakStatistic, radius_size, radius_size, exception };
11780
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(StatisticImage), &args);
11318
11781
  rm_check_exception(exception, new_image, DestroyOnError);
11319
11782
 
11320
11783
  DestroyExceptionInfo(exception);
@@ -11366,11 +11829,13 @@ Image_remap(int argc, VALUE *argv, VALUE self)
11366
11829
 
11367
11830
  #if defined(IMAGEMAGICK_7)
11368
11831
  exception = AcquireExceptionInfo();
11369
- RemapImage(&quantize_info, image, remap_image, exception);
11832
+ GVL_STRUCT_TYPE(RemapImage) args = { &quantize_info, image, remap_image, exception };
11833
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemapImage), &args);
11370
11834
  CHECK_EXCEPTION();
11371
11835
  DestroyExceptionInfo(exception);
11372
11836
  #else
11373
- RemapImage(&quantize_info, image, remap_image);
11837
+ GVL_STRUCT_TYPE(RemapImage) args = { &quantize_info, image, remap_image };
11838
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RemapImage), &args);
11374
11839
  rm_check_image_exception(image, RetainOnError);
11375
11840
  #endif
11376
11841
 
@@ -11425,11 +11890,13 @@ blurred_image(Image* image, double blur)
11425
11890
  exception = AcquireExceptionInfo();
11426
11891
  if (blur > 1.0)
11427
11892
  {
11428
- new_image = BlurImage(image, blur, blur, exception);
11893
+ GVL_STRUCT_TYPE(BlurImage) args = { image, blur, blur, exception };
11894
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BlurImage), &args);
11429
11895
  }
11430
11896
  else
11431
11897
  {
11432
- new_image = SharpenImage(image, blur, blur, exception);
11898
+ GVL_STRUCT_TYPE(SharpenImage) args = { image, blur, blur, exception };
11899
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SharpenImage), &args);
11433
11900
  }
11434
11901
  rm_check_exception(exception, new_image, DestroyOnError);
11435
11902
  DestroyExceptionInfo(exception);
@@ -11462,7 +11929,7 @@ resample(int bang, int argc, VALUE *argv, VALUE self)
11462
11929
  double width, height;
11463
11930
  ExceptionInfo *exception;
11464
11931
 
11465
- Data_Get_Struct(self, Image, image);
11932
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
11466
11933
 
11467
11934
  // Set up defaults
11468
11935
  filter = image->filter;
@@ -11522,10 +11989,12 @@ resample(int bang, int argc, VALUE *argv, VALUE self)
11522
11989
  exception = AcquireExceptionInfo();
11523
11990
  #if defined(IMAGEMAGICK_7)
11524
11991
  Image *preprocess = blurred_image(image, blur);
11525
- new_image = ResampleImage(preprocess, x_resolution, y_resolution, filter, exception);
11992
+ GVL_STRUCT_TYPE(ResampleImage) args = { preprocess, x_resolution, y_resolution, filter, exception };
11993
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ResampleImage), &args);
11526
11994
  DestroyImage(preprocess);
11527
11995
  #else
11528
- new_image = ResampleImage(image, x_resolution, y_resolution, filter, blur, exception);
11996
+ GVL_STRUCT_TYPE(ResampleImage) args = { image, x_resolution, y_resolution, filter, blur, exception };
11997
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ResampleImage), &args);
11529
11998
  #endif
11530
11999
  rm_check_exception(exception, new_image, DestroyOnError);
11531
12000
 
@@ -11612,7 +12081,7 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
11612
12081
  double blur, drows, dcols;
11613
12082
  ExceptionInfo *exception;
11614
12083
 
11615
- Data_Get_Struct(self, Image, image);
12084
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
11616
12085
 
11617
12086
  // Set up defaults
11618
12087
  filter = image->filter;
@@ -11661,13 +12130,15 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
11661
12130
  exception = AcquireExceptionInfo();
11662
12131
  #if defined(IMAGEMAGICK_7)
11663
12132
  Image *preprocess = (argc == 4) ? blurred_image(image, blur) : image;
11664
- new_image = ResizeImage(preprocess, columns, rows, filter, exception);
12133
+ GVL_STRUCT_TYPE(ResizeImage) args = { preprocess, columns, rows, filter, exception };
12134
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ResizeImage), &args);
11665
12135
  if (argc == 4)
11666
12136
  {
11667
12137
  DestroyImage(preprocess);
11668
12138
  }
11669
12139
  #else
11670
- new_image = ResizeImage(image, columns, rows, filter, blur, exception);
12140
+ GVL_STRUCT_TYPE(ResizeImage) args = { image, columns, rows, filter, blur, exception };
12141
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ResizeImage), &args);
11671
12142
  #endif
11672
12143
  rm_check_exception(exception, new_image, DestroyOnError);
11673
12144
 
@@ -11753,7 +12224,8 @@ Image_roll(VALUE self, VALUE x_offset, VALUE y_offset)
11753
12224
  image = rm_check_destroyed(self);
11754
12225
 
11755
12226
  exception = AcquireExceptionInfo();
11756
- new_image = RollImage(image, x, y, exception);
12227
+ GVL_STRUCT_TYPE(RollImage) args = { image, x, y, exception };
12228
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RollImage), &args);
11757
12229
  rm_check_exception(exception, new_image, DestroyOnError);
11758
12230
  DestroyExceptionInfo(exception);
11759
12231
 
@@ -11783,7 +12255,7 @@ rotate(int bang, int argc, VALUE *argv, VALUE self)
11783
12255
  long arrow_l;
11784
12256
  ExceptionInfo *exception;
11785
12257
 
11786
- Data_Get_Struct(self, Image, image);
12258
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
11787
12259
 
11788
12260
  switch (argc)
11789
12261
  {
@@ -11811,7 +12283,8 @@ rotate(int bang, int argc, VALUE *argv, VALUE self)
11811
12283
 
11812
12284
  exception = AcquireExceptionInfo();
11813
12285
 
11814
- new_image = RotateImage(image, degrees, exception);
12286
+ GVL_STRUCT_TYPE(RotateImage) args = { image, degrees, exception };
12287
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RotateImage), &args);
11815
12288
  rm_check_exception(exception, new_image, DestroyOnError);
11816
12289
  DestroyExceptionInfo(exception);
11817
12290
 
@@ -11884,7 +12357,7 @@ Image_rotate_bang(int argc, VALUE *argv, VALUE self)
11884
12357
  VALUE
11885
12358
  Image_rows(VALUE self)
11886
12359
  {
11887
- IMPLEMENT_ATTR_READER(Image, rows, int);
12360
+ IMPLEMENT_TYPED_ATTR_READER(Image, rows, int, &rm_image_data_type);
11888
12361
  }
11889
12362
 
11890
12363
 
@@ -11908,7 +12381,7 @@ VALUE
11908
12381
  Image_sample(int argc, VALUE *argv, VALUE self)
11909
12382
  {
11910
12383
  rm_check_destroyed(self);
11911
- return scale(False, argc, argv, self, SampleImage);
12384
+ return scale(False, argc, argv, self, GVL_FUNC(SampleImage));
11912
12385
  }
11913
12386
 
11914
12387
 
@@ -11932,7 +12405,7 @@ VALUE
11932
12405
  Image_sample_bang(int argc, VALUE *argv, VALUE self)
11933
12406
  {
11934
12407
  rm_check_frozen(self);
11935
- return scale(True, argc, argv, self, SampleImage);
12408
+ return scale(True, argc, argv, self, GVL_FUNC(SampleImage));
11936
12409
  }
11937
12410
 
11938
12411
 
@@ -11956,7 +12429,7 @@ VALUE
11956
12429
  Image_scale(int argc, VALUE *argv, VALUE self)
11957
12430
  {
11958
12431
  rm_check_destroyed(self);
11959
- return scale(False, argc, argv, self, ScaleImage);
12432
+ return scale(False, argc, argv, self, GVL_FUNC(ScaleImage));
11960
12433
  }
11961
12434
 
11962
12435
 
@@ -11980,10 +12453,13 @@ VALUE
11980
12453
  Image_scale_bang(int argc, VALUE *argv, VALUE self)
11981
12454
  {
11982
12455
  rm_check_frozen(self);
11983
- return scale(True, argc, argv, self, ScaleImage);
12456
+ return scale(True, argc, argv, self, GVL_FUNC(ScaleImage));
11984
12457
  }
11985
12458
 
11986
12459
 
12460
+ // aliases for common use of structure types; SampleImage, ScaleImage,
12461
+ typedef GVL_STRUCT_TYPE(SampleImage) GVL_STRUCT_TYPE(scale);
12462
+
11987
12463
  /**
11988
12464
  * Call ScaleImage or SampleImage
11989
12465
  *
@@ -12005,14 +12481,14 @@ Image_scale_bang(int argc, VALUE *argv, VALUE self)
12005
12481
  * @see Image_scale_bang
12006
12482
  */
12007
12483
  static VALUE
12008
- scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
12484
+ scale(int bang, int argc, VALUE *argv, VALUE self, gvl_function_t fp)
12009
12485
  {
12010
12486
  Image *image, *new_image;
12011
12487
  unsigned long columns, rows;
12012
12488
  double scale_arg, drows, dcols;
12013
12489
  ExceptionInfo *exception;
12014
12490
 
12015
- Data_Get_Struct(self, Image, image);
12491
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
12016
12492
 
12017
12493
  switch (argc)
12018
12494
  {
@@ -12045,7 +12521,8 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
12045
12521
  }
12046
12522
 
12047
12523
  exception = AcquireExceptionInfo();
12048
- new_image = (scaler)(image, columns, rows, exception);
12524
+ GVL_STRUCT_TYPE(scale) args = { image, columns, rows, exception };
12525
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
12049
12526
  rm_check_exception(exception, new_image, DestroyOnError);
12050
12527
  DestroyExceptionInfo(exception);
12051
12528
 
@@ -12070,7 +12547,7 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
12070
12547
  VALUE
12071
12548
  Image_scene(VALUE self)
12072
12549
  {
12073
- IMPLEMENT_ATTR_READER(Image, scene, ulong);
12550
+ IMPLEMENT_TYPED_ATTR_READER(Image, scene, ulong, &rm_image_data_type);
12074
12551
  }
12075
12552
 
12076
12553
 
@@ -12121,11 +12598,13 @@ Image_selective_blur_channel(int argc, VALUE *argv, VALUE self)
12121
12598
  exception = AcquireExceptionInfo();
12122
12599
  #if defined(IMAGEMAGICK_7)
12123
12600
  BEGIN_CHANNEL_MASK(image, channels);
12124
- new_image = SelectiveBlurImage(image, radius, sigma, threshold, exception);
12601
+ GVL_STRUCT_TYPE(SelectiveBlurImage) args = { image, radius, sigma, threshold, exception };
12602
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SelectiveBlurImage), &args);
12125
12603
  CHANGE_RESULT_CHANNEL_MASK(new_image);
12126
12604
  END_CHANNEL_MASK(image);
12127
12605
  #else
12128
- new_image = SelectiveBlurImageChannel(image, channels, radius, sigma, threshold, exception);
12606
+ GVL_STRUCT_TYPE(SelectiveBlurImageChannel) args = { image, channels, radius, sigma, threshold, exception };
12607
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SelectiveBlurImageChannel), &args);
12129
12608
  #endif
12130
12609
  rm_check_exception(exception, new_image, DestroyOnError);
12131
12610
  DestroyExceptionInfo(exception);
@@ -12159,12 +12638,14 @@ Image_set_channel_depth(VALUE self, VALUE channel_arg, VALUE depth)
12159
12638
  #if defined(IMAGEMAGICK_7)
12160
12639
  exception = AcquireExceptionInfo();
12161
12640
  BEGIN_CHANNEL_MASK(image, channel);
12162
- SetImageDepth(image, channel_depth, exception);
12641
+ GVL_STRUCT_TYPE(SetImageDepth) args = { image, channel_depth, exception };
12642
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageDepth), &args);
12163
12643
  END_CHANNEL_MASK(image);
12164
12644
  CHECK_EXCEPTION();
12165
12645
  DestroyExceptionInfo(exception);
12166
12646
  #else
12167
- SetImageChannelDepth(image, channel, channel_depth);
12647
+ GVL_STRUCT_TYPE(SetImageChannelDepth) args = { image, channel, channel_depth };
12648
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageChannelDepth), &args);
12168
12649
  rm_check_image_exception(image, RetainOnError);
12169
12650
  #endif
12170
12651
 
@@ -12202,11 +12683,13 @@ Image_separate(int argc, VALUE *argv, VALUE self)
12202
12683
  exception = AcquireExceptionInfo();
12203
12684
  #if defined(IMAGEMAGICK_7)
12204
12685
  BEGIN_CHANNEL_MASK(image, channels);
12205
- new_images = SeparateImages(image, exception);
12686
+ GVL_STRUCT_TYPE(SeparateImages) args = { image, exception };
12687
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SeparateImages), &args);
12206
12688
  CHANGE_RESULT_CHANNEL_MASK(new_images);
12207
12689
  END_CHANNEL_MASK(image);
12208
12690
  #else
12209
- new_images = SeparateImages(image, channels, exception);
12691
+ GVL_STRUCT_TYPE(SeparateImages) args = { image, channels, exception };
12692
+ new_images = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SeparateImages), &args);
12210
12693
  #endif
12211
12694
  rm_check_exception(exception, new_images, DestroyOnError);
12212
12695
  DestroyExceptionInfo(exception);
@@ -12245,7 +12728,8 @@ Image_sepiatone(int argc, VALUE *argv, VALUE self)
12245
12728
  }
12246
12729
 
12247
12730
  exception = AcquireExceptionInfo();
12248
- new_image = SepiaToneImage(image, threshold, exception);
12731
+ GVL_STRUCT_TYPE(SepiaToneImage) args = { image, threshold, exception };
12732
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SepiaToneImage), &args);
12249
12733
  rm_check_exception(exception, new_image, DestroyOnError);
12250
12734
  DestroyExceptionInfo(exception);
12251
12735
 
@@ -12303,11 +12787,13 @@ Image_segment(int argc, VALUE *argv, VALUE self)
12303
12787
 
12304
12788
  #if defined(IMAGEMAGICK_7)
12305
12789
  exception = AcquireExceptionInfo();
12306
- SegmentImage(new_image, colorspace, verbose, cluster_threshold, smoothing_threshold, exception);
12790
+ GVL_STRUCT_TYPE(SegmentImage) args = { new_image, colorspace, verbose, cluster_threshold, smoothing_threshold, exception };
12791
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SegmentImage), &args);
12307
12792
  rm_check_exception(exception, new_image, DestroyOnError);
12308
12793
  DestroyExceptionInfo(exception);
12309
12794
  #else
12310
- SegmentImage(new_image, colorspace, verbose, cluster_threshold, smoothing_threshold);
12795
+ GVL_STRUCT_TYPE(SegmentImage) args = { new_image, colorspace, verbose, cluster_threshold, smoothing_threshold };
12796
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SegmentImage), &args);
12311
12797
  rm_check_image_exception(new_image, DestroyOnError);
12312
12798
  #endif
12313
12799
 
@@ -12325,7 +12811,7 @@ Image_segment(int argc, VALUE *argv, VALUE self)
12325
12811
  * @return [Hash] the properties
12326
12812
  *
12327
12813
  * @overload properties
12328
- * @yield []
12814
+ * @yield [Magick::Image::Info]
12329
12815
  * @return [Magick::Image] self
12330
12816
  */
12331
12817
  VALUE
@@ -12443,7 +12929,8 @@ Image_shade(int argc, VALUE *argv, VALUE self)
12443
12929
  }
12444
12930
 
12445
12931
  exception = AcquireExceptionInfo();
12446
- new_image = ShadeImage(image, shading, azimuth, elevation, exception);
12932
+ GVL_STRUCT_TYPE(ShadeImage) args = { image, shading, azimuth, elevation, exception };
12933
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ShadeImage), &args);
12447
12934
  rm_check_exception(exception, new_image, DestroyOnError);
12448
12935
  DestroyExceptionInfo(exception);
12449
12936
 
@@ -12501,7 +12988,8 @@ Image_shadow(int argc, VALUE *argv, VALUE self)
12501
12988
  }
12502
12989
 
12503
12990
  exception = AcquireExceptionInfo();
12504
- new_image = ShadowImage(image, alpha, sigma, x_offset, y_offset, exception);
12991
+ GVL_STRUCT_TYPE(ShadowImage) args = { image, alpha, sigma, x_offset, y_offset, exception };
12992
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ShadowImage), &args);
12505
12993
  rm_check_exception(exception, new_image, DestroyOnError);
12506
12994
  DestroyExceptionInfo(exception);
12507
12995
 
@@ -12520,7 +13008,7 @@ Image_shadow(int argc, VALUE *argv, VALUE self)
12520
13008
  VALUE
12521
13009
  Image_sharpen(int argc, VALUE *argv, VALUE self)
12522
13010
  {
12523
- return effect_image(self, argc, argv, SharpenImage);
13011
+ return effect_image(self, argc, argv, GVL_FUNC(SharpenImage));
12524
13012
  }
12525
13013
 
12526
13014
 
@@ -12568,11 +13056,13 @@ Image_sharpen_channel(int argc, VALUE *argv, VALUE self)
12568
13056
  exception = AcquireExceptionInfo();
12569
13057
  #if defined(IMAGEMAGICK_7)
12570
13058
  BEGIN_CHANNEL_MASK(image, channels);
12571
- new_image = SharpenImage(image, radius, sigma, exception);
13059
+ GVL_STRUCT_TYPE(SharpenImage) args = { image, radius, sigma, exception };
13060
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SharpenImage), &args);
12572
13061
  CHANGE_RESULT_CHANNEL_MASK(new_image);
12573
13062
  END_CHANNEL_MASK(image);
12574
13063
  #else
12575
- new_image = SharpenImageChannel(image, channels, radius, sigma, exception);
13064
+ GVL_STRUCT_TYPE(SharpenImageChannel) args = { image, channels, radius, sigma, exception };
13065
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SharpenImageChannel), &args);
12576
13066
  #endif
12577
13067
 
12578
13068
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -12595,7 +13085,7 @@ VALUE
12595
13085
  Image_shave(VALUE self, VALUE width, VALUE height)
12596
13086
  {
12597
13087
  rm_check_destroyed(self);
12598
- return xform_image(False, self, INT2FIX(0), INT2FIX(0), width, height, ShaveImage);
13088
+ return xform_image(False, self, INT2FIX(0), INT2FIX(0), width, height, GVL_FUNC(ShaveImage));
12599
13089
  }
12600
13090
 
12601
13091
 
@@ -12613,7 +13103,7 @@ VALUE
12613
13103
  Image_shave_bang(VALUE self, VALUE width, VALUE height)
12614
13104
  {
12615
13105
  rm_check_frozen(self);
12616
- return xform_image(True, self, INT2FIX(0), INT2FIX(0), width, height, ShaveImage);
13106
+ return xform_image(True, self, INT2FIX(0), INT2FIX(0), width, height, GVL_FUNC(ShaveImage));
12617
13107
  }
12618
13108
 
12619
13109
 
@@ -12640,7 +13130,8 @@ Image_shear(VALUE self, VALUE x_shear, VALUE y_shear)
12640
13130
  image = rm_check_destroyed(self);
12641
13131
 
12642
13132
  exception = AcquireExceptionInfo();
12643
- new_image = ShearImage(image, x, y, exception);
13133
+ GVL_STRUCT_TYPE(ShearImage) args = { image, x, y, exception };
13134
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ShearImage), &args);
12644
13135
  rm_check_exception(exception, new_image, DestroyOnError);
12645
13136
  DestroyExceptionInfo(exception);
12646
13137
 
@@ -12711,12 +13202,14 @@ Image_sigmoidal_contrast_channel(int argc, VALUE *argv, VALUE self)
12711
13202
  #if defined(IMAGEMAGICK_7)
12712
13203
  exception = AcquireExceptionInfo();
12713
13204
  BEGIN_CHANNEL_MASK(new_image, channels);
12714
- SigmoidalContrastImage(new_image, sharpen, contrast, midpoint, exception);
13205
+ GVL_STRUCT_TYPE(SigmoidalContrastImage) args = { new_image, sharpen, contrast, midpoint, exception };
13206
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SigmoidalContrastImage), &args);
12715
13207
  END_CHANNEL_MASK(new_image);
12716
13208
  rm_check_exception(exception, new_image, DestroyOnError);
12717
13209
  DestroyExceptionInfo(exception);
12718
13210
  #else
12719
- SigmoidalContrastImageChannel(new_image, channels, sharpen, contrast, midpoint);
13211
+ GVL_STRUCT_TYPE(SigmoidalContrastImageChannel) args = { new_image, channels, sharpen, contrast, midpoint };
13212
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SigmoidalContrastImageChannel), &args);
12720
13213
  rm_check_image_exception(new_image, DestroyOnError);
12721
13214
  #endif
12722
13215
 
@@ -12743,11 +13236,13 @@ Image_signature(VALUE self)
12743
13236
 
12744
13237
  #if defined(IMAGEMAGICK_7)
12745
13238
  exception = AcquireExceptionInfo();
12746
- SignatureImage(image, exception);
13239
+ GVL_STRUCT_TYPE(SignatureImage) args = { image, exception };
13240
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args);
12747
13241
  CHECK_EXCEPTION();
12748
13242
  DestroyExceptionInfo(exception);
12749
13243
  #else
12750
- SignatureImage(image);
13244
+ GVL_STRUCT_TYPE(SignatureImage) args = { image };
13245
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args);
12751
13246
  rm_check_image_exception(image, RetainOnError);
12752
13247
  #endif
12753
13248
  signature = rm_get_property(image, "signature");
@@ -12773,7 +13268,7 @@ VALUE
12773
13268
  Image_sketch(int argc, VALUE *argv, VALUE self)
12774
13269
  {
12775
13270
  rm_check_destroyed(self);
12776
- return motion_blur(argc, argv, self, SketchImage);
13271
+ return motion_blur(argc, argv, self, GVL_FUNC(SketchImage));
12777
13272
  }
12778
13273
 
12779
13274
 
@@ -12816,11 +13311,13 @@ Image_solarize(int argc, VALUE *argv, VALUE self)
12816
13311
 
12817
13312
  #if defined(IMAGEMAGICK_7)
12818
13313
  exception = AcquireExceptionInfo();
12819
- SolarizeImage(new_image, threshold, exception);
13314
+ GVL_STRUCT_TYPE(SolarizeImage) args = { new_image, threshold, exception };
13315
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SolarizeImage), &args);
12820
13316
  rm_check_exception(exception, new_image, DestroyOnError);
12821
13317
  DestroyExceptionInfo(exception);
12822
13318
  #else
12823
- SolarizeImage(new_image, threshold);
13319
+ GVL_STRUCT_TYPE(SolarizeImage) args = { new_image, threshold };
13320
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SolarizeImage), &args);
12824
13321
  rm_check_image_exception(new_image, DestroyOnError);
12825
13322
  #endif
12826
13323
 
@@ -12856,14 +13353,18 @@ Image_spaceship(VALUE self, VALUE other)
12856
13353
 
12857
13354
  #if defined(IMAGEMAGICK_7)
12858
13355
  exception = AcquireExceptionInfo();
12859
- SignatureImage(imageA, exception);
13356
+ GVL_STRUCT_TYPE(SignatureImage) args1 = { imageA, exception };
13357
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args1);
12860
13358
  CHECK_EXCEPTION();
12861
- SignatureImage(imageB, exception);
13359
+ GVL_STRUCT_TYPE(SignatureImage) args2 = { imageB, exception };
13360
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args2);
12862
13361
  CHECK_EXCEPTION();
12863
13362
  DestroyExceptionInfo(exception);
12864
13363
  #else
12865
- SignatureImage(imageA);
12866
- SignatureImage(imageB);
13364
+ GVL_STRUCT_TYPE(SignatureImage) args1 = { imageA };
13365
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args1);
13366
+ GVL_STRUCT_TYPE(SignatureImage) args2 = { imageB };
13367
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args2);
12867
13368
  #endif
12868
13369
  sigA = rm_get_property(imageA, "signature");
12869
13370
  sigB = rm_get_property(imageB, "signature");
@@ -13040,11 +13541,13 @@ Image_sparse_color(int argc, VALUE *argv, VALUE self)
13040
13541
  exception = AcquireExceptionInfo();
13041
13542
  #if defined(IMAGEMAGICK_7)
13042
13543
  BEGIN_CHANNEL_MASK(image, channels);
13043
- new_image = SparseColorImage(image, method, nargs, args, exception);
13544
+ GVL_STRUCT_TYPE(SparseColorImage) args_SparseColorImage = { image, method, nargs, args, exception };
13545
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SparseColorImage), &args_SparseColorImage);
13044
13546
  CHANGE_RESULT_CHANNEL_MASK(new_image);
13045
13547
  END_CHANNEL_MASK(image);
13046
13548
  #else
13047
- new_image = SparseColorImage(image, channels, method, nargs, args, exception);
13549
+ GVL_STRUCT_TYPE(SparseColorImage) args_SparseColorImage = { image, channels, method, nargs, args, exception };
13550
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SparseColorImage), &args_SparseColorImage);
13048
13551
  #endif
13049
13552
  xfree((void *) args);
13050
13553
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -13103,7 +13606,8 @@ Image_splice(int argc, VALUE *argv, VALUE self)
13103
13606
  // Swap in color for the duration of this call.
13104
13607
  old_color = image->background_color;
13105
13608
  image->background_color = color;
13106
- new_image = SpliceImage(image, &rectangle, exception);
13609
+ GVL_STRUCT_TYPE(SpliceImage) args = { image, &rectangle, exception };
13610
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SpliceImage), &args);
13107
13611
  image->background_color = old_color;
13108
13612
 
13109
13613
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -13141,10 +13645,11 @@ Image_spread(int argc, VALUE *argv, VALUE self)
13141
13645
 
13142
13646
  exception = AcquireExceptionInfo();
13143
13647
  #if defined(IMAGEMAGICK_7)
13144
- new_image = SpreadImage(image, image->interpolate, radius, exception);
13648
+ GVL_STRUCT_TYPE(SpreadImage) args = { image, image->interpolate, radius, exception };
13145
13649
  #else
13146
- new_image = SpreadImage(image, radius, exception);
13650
+ GVL_STRUCT_TYPE(SpreadImage) args = { image, radius, exception };
13147
13651
  #endif
13652
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SpreadImage), &args);
13148
13653
  rm_check_exception(exception, new_image, DestroyOnError);
13149
13654
  DestroyExceptionInfo(exception);
13150
13655
 
@@ -13160,7 +13665,7 @@ Image_spread(int argc, VALUE *argv, VALUE self)
13160
13665
  VALUE
13161
13666
  Image_start_loop(VALUE self)
13162
13667
  {
13163
- IMPLEMENT_ATTR_READER(Image, start_loop, boolean);
13668
+ IMPLEMENT_TYPED_ATTR_READER(Image, start_loop, boolean, &rm_image_data_type);
13164
13669
  }
13165
13670
 
13166
13671
  /**
@@ -13172,7 +13677,7 @@ Image_start_loop(VALUE self)
13172
13677
  VALUE
13173
13678
  Image_start_loop_eq(VALUE self, VALUE val)
13174
13679
  {
13175
- IMPLEMENT_ATTR_WRITER(Image, start_loop, boolean);
13680
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, start_loop, boolean, &rm_image_data_type);
13176
13681
  }
13177
13682
 
13178
13683
 
@@ -13204,7 +13709,8 @@ Image_stegano(VALUE self, VALUE watermark_image, VALUE offset)
13204
13709
  image->offset = NUM2LONG(offset);
13205
13710
 
13206
13711
  exception = AcquireExceptionInfo();
13207
- new_image = SteganoImage(image, watermark, exception);
13712
+ GVL_STRUCT_TYPE(SteganoImage) args = { image, watermark, exception };
13713
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SteganoImage), &args);
13208
13714
  rm_check_exception(exception, new_image, DestroyOnError);
13209
13715
 
13210
13716
  DestroyExceptionInfo(exception);
@@ -13236,7 +13742,8 @@ Image_stereo(VALUE self, VALUE offset_image_arg)
13236
13742
  offset = rm_check_destroyed(offset_image);
13237
13743
 
13238
13744
  exception = AcquireExceptionInfo();
13239
- new_image = StereoImage(image, offset, exception);
13745
+ GVL_STRUCT_TYPE(StereoImage) args = { image, offset, exception };
13746
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(StereoImage), &args);
13240
13747
  rm_check_exception(exception, new_image, DestroyOnError);
13241
13748
 
13242
13749
  DestroyExceptionInfo(exception);
@@ -13294,10 +13801,12 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
13294
13801
  if (image->storage_class == PseudoClass && class_type == DirectClass)
13295
13802
  {
13296
13803
  #if defined(IMAGEMAGICK_7)
13297
- SyncImage(image, exception);
13804
+ GVL_STRUCT_TYPE(SyncImage) args = { image, exception };
13805
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncImage), &args);
13298
13806
  CHECK_EXCEPTION();
13299
13807
  #else
13300
- SyncImage(image);
13808
+ GVL_STRUCT_TYPE(SyncImage) args = { image };
13809
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncImage), &args);
13301
13810
  #endif
13302
13811
  magick_free(image->colormap);
13303
13812
  image->colormap = NULL;
@@ -13307,19 +13816,23 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
13307
13816
  GetQuantizeInfo(&qinfo);
13308
13817
  qinfo.number_colors = QuantumRange+1;
13309
13818
  #if defined(IMAGEMAGICK_7)
13310
- QuantizeImage(&qinfo, image, exception);
13819
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &qinfo, image, exception };
13820
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
13311
13821
  CHECK_EXCEPTION();
13312
13822
  #else
13313
- QuantizeImage(&qinfo, image);
13823
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &qinfo, image };
13824
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
13314
13825
  #endif
13315
13826
  }
13316
13827
 
13317
13828
  #if defined(IMAGEMAGICK_7)
13318
- SetImageStorageClass(image, class_type, exception);
13829
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, class_type, exception };
13830
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13319
13831
  CHECK_EXCEPTION();
13320
13832
  DestroyExceptionInfo(exception);
13321
13833
  #else
13322
- SetImageStorageClass(image, class_type);
13834
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, class_type };
13835
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13323
13836
  #endif
13324
13837
  return new_class_type;
13325
13838
  }
@@ -13348,7 +13861,7 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13348
13861
  long n, size;
13349
13862
  long x, y;
13350
13863
  unsigned long cols, rows;
13351
- unsigned int okay;
13864
+ MagickBooleanType okay;
13352
13865
  ExceptionInfo *exception;
13353
13866
  #if defined(IMAGEMAGICK_7)
13354
13867
  Quantum *pixels;
@@ -13374,7 +13887,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13374
13887
 
13375
13888
  #if defined(IMAGEMAGICK_7)
13376
13889
  exception = AcquireExceptionInfo();
13377
- okay = SetImageStorageClass(image, DirectClass, exception);
13890
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass, exception };
13891
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13378
13892
  CHECK_EXCEPTION();
13379
13893
  if (!okay)
13380
13894
  {
@@ -13382,7 +13896,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13382
13896
  rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't store pixels.");
13383
13897
  }
13384
13898
  #else
13385
- okay = SetImageStorageClass(image, DirectClass);
13899
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
13900
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13386
13901
  rm_check_image_exception(image, RetainOnError);
13387
13902
  if (!okay)
13388
13903
  {
@@ -13394,7 +13909,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13394
13909
  // Get a pointer to the pixels. Replace the values with the PixelPackets
13395
13910
  // from the pixels argument.
13396
13911
  {
13397
- pixels = GetAuthenticPixels(image, x, y, cols, rows, exception);
13912
+ GVL_STRUCT_TYPE(GetAuthenticPixels) args = { image, x, y, cols, rows, exception };
13913
+ pixels = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetAuthenticPixels), &args);
13398
13914
  CHECK_EXCEPTION();
13399
13915
 
13400
13916
  if (pixels)
@@ -13410,7 +13926,7 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13410
13926
  DestroyExceptionInfo(exception);
13411
13927
  rb_raise(rb_eTypeError, "Item in array should be a Pixel.");
13412
13928
  }
13413
- Data_Get_Struct(new_pixel, Pixel, pixel);
13929
+ TypedData_Get_Struct(new_pixel, Pixel, &rm_pixel_data_type, pixel);
13414
13930
  #if defined(IMAGEMAGICK_7)
13415
13931
  SetPixelRed(image, pixel->red, pixels);
13416
13932
  SetPixelGreen(image, pixel->green, pixels);
@@ -13430,7 +13946,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13430
13946
  pixels++;
13431
13947
  #endif
13432
13948
  }
13433
- SyncAuthenticPixels(image, exception);
13949
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
13950
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
13434
13951
  CHECK_EXCEPTION();
13435
13952
  }
13436
13953
 
@@ -13490,10 +14007,11 @@ Image_swirl(VALUE self, VALUE degrees_obj)
13490
14007
  exception = AcquireExceptionInfo();
13491
14008
 
13492
14009
  #if defined(IMAGEMAGICK_7)
13493
- new_image = SwirlImage(image, degrees, image->interpolate, exception);
14010
+ GVL_STRUCT_TYPE(SwirlImage) args = { image, degrees, image->interpolate, exception };
13494
14011
  #else
13495
- new_image = SwirlImage(image, degrees, exception);
14012
+ GVL_STRUCT_TYPE(SwirlImage) args = { image, degrees, exception };
13496
14013
  #endif
14014
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SwirlImage), &args);
13497
14015
  rm_check_exception(exception, new_image, DestroyOnError);
13498
14016
  DestroyExceptionInfo(exception);
13499
14017
 
@@ -13584,12 +14102,14 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj,
13584
14102
 
13585
14103
  #if defined(IMAGEMAGICK_7)
13586
14104
  exception = AcquireExceptionInfo();
13587
- FloodfillPaintImage(new_image, draw_info, &color_mpp, x, y, invert, exception);
14105
+ GVL_STRUCT_TYPE(FloodfillPaintImage) args = { new_image, draw_info, &color_mpp, x, y, invert, exception };
14106
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FloodfillPaintImage), &args);
13588
14107
  DestroyDrawInfo(draw_info);
13589
14108
  rm_check_exception(exception, new_image, DestroyOnError);
13590
14109
  DestroyExceptionInfo(exception);
13591
14110
  #else
13592
- FloodfillPaintImage(new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert);
14111
+ GVL_STRUCT_TYPE(FloodfillPaintImage) args = { new_image, DefaultChannels, draw_info, &color_mpp, x, y, invert };
14112
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FloodfillPaintImage), &args);
13593
14113
 
13594
14114
  DestroyDrawInfo(draw_info);
13595
14115
  rm_check_image_exception(new_image, DestroyOnError);
@@ -13622,11 +14142,13 @@ Image_threshold(VALUE self, VALUE threshold_obj)
13622
14142
 
13623
14143
  #if defined(IMAGEMAGICK_7)
13624
14144
  exception = AcquireExceptionInfo();
13625
- BilevelImage(new_image, threshold, exception);
14145
+ GVL_STRUCT_TYPE(BilevelImage) args = { new_image, threshold, exception };
14146
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BilevelImage), &args);
13626
14147
  rm_check_exception(exception, new_image, DestroyOnError);
13627
14148
  DestroyExceptionInfo(exception);
13628
14149
  #else
13629
- BilevelImageChannel(new_image, DefaultChannels, threshold);
14150
+ GVL_STRUCT_TYPE(BilevelImageChannel) args = { new_image, DefaultChannels, threshold };
14151
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BilevelImageChannel), &args);
13630
14152
  rm_check_image_exception(new_image, DestroyOnError);
13631
14153
  #endif
13632
14154
 
@@ -13634,6 +14156,9 @@ Image_threshold(VALUE self, VALUE threshold_obj)
13634
14156
  }
13635
14157
 
13636
14158
 
14159
+ // aliases for common use of structure types; WhiteThresholdImage
14160
+ typedef GVL_STRUCT_TYPE(WhiteThresholdImage) GVL_STRUCT_TYPE(threshold_image);
14161
+
13637
14162
  /**
13638
14163
  * Call one of the xxxxThresholdImage methods.
13639
14164
  *
@@ -13645,8 +14170,8 @@ Image_threshold(VALUE self, VALUE threshold_obj)
13645
14170
  * @param thresholder which xxxxThresholdImage method to call
13646
14171
  * @return a new image
13647
14172
  */
13648
- static
13649
- VALUE threshold_image(int argc, VALUE *argv, VALUE self, thresholder_t thresholder)
14173
+ static VALUE
14174
+ threshold_image(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
13650
14175
  {
13651
14176
  Image *image, *new_image;
13652
14177
  double red, green, blue, alpha;
@@ -13689,11 +14214,13 @@ VALUE threshold_image(int argc, VALUE *argv, VALUE self, thresholder_t threshold
13689
14214
 
13690
14215
  #if defined(IMAGEMAGICK_7)
13691
14216
  exception = AcquireExceptionInfo();
13692
- (thresholder)(new_image, ctarg, exception);
14217
+ GVL_STRUCT_TYPE(threshold_image) args = { new_image, ctarg, exception };
14218
+ CALL_FUNC_WITHOUT_GVL(fp, &args);
13693
14219
  rm_check_exception(exception, new_image, DestroyOnError);
13694
14220
  DestroyExceptionInfo(exception);
13695
14221
  #else
13696
- (thresholder)(new_image, ctarg);
14222
+ GVL_STRUCT_TYPE(threshold_image) args = { new_image, ctarg };
14223
+ CALL_FUNC_WITHOUT_GVL(fp, &args);
13697
14224
  rm_check_image_exception(new_image, DestroyOnError);
13698
14225
  #endif
13699
14226
 
@@ -13727,7 +14254,7 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
13727
14254
  RectangleInfo geometry;
13728
14255
  ExceptionInfo *exception;
13729
14256
 
13730
- Data_Get_Struct(self, Image, image);
14257
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
13731
14258
 
13732
14259
  switch (argc)
13733
14260
  {
@@ -13765,7 +14292,8 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
13765
14292
  ParseRegionGeometry(image, image_geometry, &geometry, exception);
13766
14293
  rm_check_exception(exception, image, RetainOnError);
13767
14294
 
13768
- new_image = ThumbnailImage(image, geometry.width, geometry.height, exception);
14295
+ GVL_STRUCT_TYPE(ThumbnailImage) args = { image, geometry.width, geometry.height, exception };
14296
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ThumbnailImage), &args);
13769
14297
  rm_check_exception(exception, new_image, DestroyOnError);
13770
14298
  DestroyExceptionInfo(exception);
13771
14299
 
@@ -13923,10 +14451,11 @@ Image_tint(int argc, VALUE *argv, VALUE self)
13923
14451
  exception = AcquireExceptionInfo();
13924
14452
 
13925
14453
  #if defined(IMAGEMAGICK_7)
13926
- new_image = TintImage(image, alpha, &tint, exception);
14454
+ GVL_STRUCT_TYPE(TintImage) args = { image, alpha, &tint, exception };
13927
14455
  #else
13928
- new_image = TintImage(image, alpha, tint, exception);
14456
+ GVL_STRUCT_TYPE(TintImage) args = { image, alpha, tint, exception };
13929
14457
  #endif
14458
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TintImage), &args);
13930
14459
  rm_check_exception(exception, new_image, DestroyOnError);
13931
14460
  DestroyExceptionInfo(exception);
13932
14461
 
@@ -13959,7 +14488,7 @@ Image_to_blob(VALUE self)
13959
14488
  // both) and the image format by setting the depth and format
13960
14489
  // values in the info parm block.
13961
14490
  info_obj = rm_info_new();
13962
- Data_Get_Struct(info_obj, Info, info);
14491
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
13963
14492
 
13964
14493
  image = rm_check_destroyed(self);
13965
14494
 
@@ -13969,10 +14498,12 @@ Image_to_blob(VALUE self)
13969
14498
  if (info->depth != 0)
13970
14499
  {
13971
14500
  #if defined(IMAGEMAGICK_7)
13972
- SetImageDepth(image, info->depth, exception);
14501
+ GVL_STRUCT_TYPE(SetImageDepth) args = { image, info->depth, exception };
14502
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageDepth), &args);
13973
14503
  CHECK_EXCEPTION();
13974
14504
  #else
13975
- SetImageDepth(image, info->depth);
14505
+ GVL_STRUCT_TYPE(SetImageDepth) args = { image, info->depth };
14506
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageDepth), &args);
13976
14507
  rm_check_image_exception(image, RetainOnError);
13977
14508
  #endif
13978
14509
  }
@@ -14006,7 +14537,8 @@ Image_to_blob(VALUE self)
14006
14537
 
14007
14538
  rm_sync_image_options(image, info);
14008
14539
 
14009
- blob = ImageToBlob(info, image, &length, exception);
14540
+ GVL_STRUCT_TYPE(ImageToBlob) args = { info, image, &length, exception };
14541
+ blob = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImageToBlob), &args);
14010
14542
  CHECK_EXCEPTION();
14011
14543
 
14012
14544
  DestroyExceptionInfo(exception);
@@ -14152,11 +14684,13 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
14152
14684
 
14153
14685
  #if defined(IMAGEMAGICK_7)
14154
14686
  exception = AcquireExceptionInfo();
14155
- okay = TransparentPaintImage(new_image, &color, alpha, MagickFalse, exception);
14687
+ GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, alpha, MagickFalse, exception };
14688
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
14156
14689
  rm_check_exception(exception, new_image, DestroyOnError);
14157
14690
  DestroyExceptionInfo(exception);
14158
14691
  #else
14159
- okay = TransparentPaintImage(new_image, &color, QuantumRange - alpha, MagickFalse);
14692
+ GVL_STRUCT_TYPE(TransparentPaintImage) args = { new_image, &color, QuantumRange - alpha, MagickFalse };
14693
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImage), &args);
14160
14694
  rm_check_image_exception(new_image, DestroyOnError);
14161
14695
  #endif
14162
14696
  if (!okay)
@@ -14226,11 +14760,13 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
14226
14760
 
14227
14761
  #if defined(IMAGEMAGICK_7)
14228
14762
  exception = AcquireExceptionInfo();
14229
- okay = TransparentPaintImageChroma(new_image, &low, &high, alpha, invert, exception);
14763
+ GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, alpha, invert, exception };
14764
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
14230
14765
  rm_check_exception(exception, new_image, DestroyOnError);
14231
14766
  DestroyExceptionInfo(exception);
14232
14767
  #else
14233
- okay = TransparentPaintImageChroma(new_image, &low, &high, QuantumRange - alpha, invert);
14768
+ GVL_STRUCT_TYPE(TransparentPaintImageChroma) args = { new_image, &low, &high, QuantumRange - alpha, invert };
14769
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TransparentPaintImageChroma), &args);
14234
14770
  rm_check_image_exception(new_image, DestroyOnError);
14235
14771
  #endif
14236
14772
  if (!okay)
@@ -14283,7 +14819,7 @@ VALUE
14283
14819
  Image_transpose(VALUE self)
14284
14820
  {
14285
14821
  rm_check_destroyed(self);
14286
- return crisscross(False, self, TransposeImage);
14822
+ return crisscross(False, self, GVL_FUNC(TransposeImage));
14287
14823
  }
14288
14824
 
14289
14825
 
@@ -14299,7 +14835,7 @@ VALUE
14299
14835
  Image_transpose_bang(VALUE self)
14300
14836
  {
14301
14837
  rm_check_frozen(self);
14302
- return crisscross(True, self, TransposeImage);
14838
+ return crisscross(True, self, GVL_FUNC(TransposeImage));
14303
14839
  }
14304
14840
 
14305
14841
 
@@ -14314,7 +14850,7 @@ VALUE
14314
14850
  Image_transverse(VALUE self)
14315
14851
  {
14316
14852
  rm_check_destroyed(self);
14317
- return crisscross(False, self, TransverseImage);
14853
+ return crisscross(False, self, GVL_FUNC(TransverseImage));
14318
14854
  }
14319
14855
 
14320
14856
  /**
@@ -14329,7 +14865,7 @@ VALUE
14329
14865
  Image_transverse_bang(VALUE self)
14330
14866
  {
14331
14867
  rm_check_frozen(self);
14332
- return crisscross(True, self, TransverseImage);
14868
+ return crisscross(True, self, GVL_FUNC(TransverseImage));
14333
14869
  }
14334
14870
 
14335
14871
 
@@ -14367,10 +14903,11 @@ trimmer(int bang, int argc, VALUE *argv, VALUE self)
14367
14903
  break;
14368
14904
  }
14369
14905
 
14370
- Data_Get_Struct(self, Image, image);
14906
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
14371
14907
 
14372
14908
  exception = AcquireExceptionInfo();
14373
- new_image = TrimImage(image, exception);
14909
+ GVL_STRUCT_TYPE(TrimImage) args = { image, exception };
14910
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TrimImage), &args);
14374
14911
  rm_check_exception(exception, new_image, DestroyOnError);
14375
14912
  DestroyExceptionInfo(exception);
14376
14913
 
@@ -14551,7 +15088,8 @@ Image_unique_colors(VALUE self)
14551
15088
  image = rm_check_destroyed(self);
14552
15089
  exception = AcquireExceptionInfo();
14553
15090
 
14554
- new_image = UniqueImageColors(image, exception);
15091
+ GVL_STRUCT_TYPE(UniqueImageColors) args = { image, exception };
15092
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UniqueImageColors), &args);
14555
15093
  rm_check_exception(exception, new_image, DestroyOnError);
14556
15094
  DestroyExceptionInfo(exception);
14557
15095
 
@@ -14717,7 +15255,8 @@ Image_unsharp_mask(int argc, VALUE *argv, VALUE self)
14717
15255
  unsharp_mask_args(argc, argv, &radius, &sigma, &amount, &threshold);
14718
15256
 
14719
15257
  exception = AcquireExceptionInfo();
14720
- new_image = UnsharpMaskImage(image, radius, sigma, amount, threshold, exception);
15258
+ GVL_STRUCT_TYPE(UnsharpMaskImage) args = { image, radius, sigma, amount, threshold, exception };
15259
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnsharpMaskImage), &args);
14721
15260
  rm_check_exception(exception, new_image, DestroyOnError);
14722
15261
  DestroyExceptionInfo(exception);
14723
15262
 
@@ -14772,11 +15311,13 @@ Image_unsharp_mask_channel(int argc, VALUE *argv, VALUE self)
14772
15311
  exception = AcquireExceptionInfo();
14773
15312
  #if defined(IMAGEMAGICK_7)
14774
15313
  BEGIN_CHANNEL_MASK(image, channels);
14775
- new_image = UnsharpMaskImage(image, radius, sigma, amount, threshold, exception);
15314
+ GVL_STRUCT_TYPE(UnsharpMaskImage) args = { image, radius, sigma, amount, threshold, exception };
15315
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnsharpMaskImage), &args);
14776
15316
  CHANGE_RESULT_CHANNEL_MASK(new_image);
14777
15317
  END_CHANNEL_MASK(image);
14778
15318
  #else
14779
- new_image = UnsharpMaskImageChannel(image, channels, radius, sigma, amount, threshold, exception);
15319
+ GVL_STRUCT_TYPE(UnsharpMaskImageChannel) args = { image, channels, radius, sigma, amount, threshold, exception };
15320
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(UnsharpMaskImageChannel), &args);
14780
15321
  #endif
14781
15322
  rm_check_exception(exception, new_image, DestroyOnError);
14782
15323
  DestroyExceptionInfo(exception);
@@ -14827,7 +15368,8 @@ Image_vignette(int argc, VALUE *argv, VALUE self)
14827
15368
 
14828
15369
  exception = AcquireExceptionInfo();
14829
15370
 
14830
- new_image = VignetteImage(image, radius, sigma, horz_radius, vert_radius, exception);
15371
+ GVL_STRUCT_TYPE(VignetteImage) args = { image, radius, sigma, horz_radius, vert_radius, exception };
15372
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(VignetteImage), &args);
14831
15373
  rm_check_exception(exception, new_image, DestroyOnError);
14832
15374
  DestroyExceptionInfo(exception);
14833
15375
 
@@ -14973,11 +15515,13 @@ Image_watermark(int argc, VALUE *argv, VALUE self)
14973
15515
  new_image = rm_clone_image(image);
14974
15516
  #if defined(IMAGEMAGICK_7)
14975
15517
  exception = AcquireExceptionInfo();
14976
- CompositeImage(new_image, overlay, ModulateCompositeOp, MagickTrue, x_offset, y_offset, exception);
15518
+ GVL_STRUCT_TYPE(CompositeImage) args = { new_image, overlay, ModulateCompositeOp, MagickTrue, x_offset, y_offset, exception };
15519
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
14977
15520
  rm_check_exception(exception, new_image, DestroyOnError);
14978
15521
  DestroyExceptionInfo(exception);
14979
15522
  #else
14980
- CompositeImage(new_image, ModulateCompositeOp, overlay, x_offset, y_offset);
15523
+ GVL_STRUCT_TYPE(CompositeImage) args = { new_image, ModulateCompositeOp, overlay, x_offset, y_offset };
15524
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CompositeImage), &args);
14981
15525
 
14982
15526
  rm_check_image_exception(new_image, DestroyOnError);
14983
15527
  #endif
@@ -15020,10 +15564,11 @@ Image_wave(int argc, VALUE *argv, VALUE self)
15020
15564
 
15021
15565
  exception = AcquireExceptionInfo();
15022
15566
  #if defined(IMAGEMAGICK_7)
15023
- new_image = WaveImage(image, amplitude, wavelength, image->interpolate, exception);
15567
+ GVL_STRUCT_TYPE(WaveImage) args = { image, amplitude, wavelength, image->interpolate, exception };
15024
15568
  #else
15025
- new_image = WaveImage(image, amplitude, wavelength, exception);
15569
+ GVL_STRUCT_TYPE(WaveImage) args = { image, amplitude, wavelength, exception };
15026
15570
  #endif
15571
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WaveImage), &args);
15027
15572
  rm_check_exception(exception, new_image, DestroyOnError);
15028
15573
  DestroyExceptionInfo(exception);
15029
15574
 
@@ -15119,7 +15664,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15119
15664
 
15120
15665
 
15121
15666
  exception = AcquireExceptionInfo();
15122
- flip_image = FlipImage(image, exception);
15667
+ GVL_STRUCT_TYPE(FlipImage) args_FlipImage = { image, exception };
15668
+ flip_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FlipImage), &args_FlipImage);
15123
15669
  CHECK_EXCEPTION();
15124
15670
 
15125
15671
 
@@ -15127,18 +15673,22 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15127
15673
  geometry.y = 0;
15128
15674
  geometry.width = image->columns;
15129
15675
  geometry.height = max_rows;
15130
- reflection = CropImage(flip_image, &geometry, exception);
15676
+ GVL_STRUCT_TYPE(CropImage) args_CropImage = { flip_image, &geometry, exception };
15677
+ reflection = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(CropImage), &args_CropImage);
15131
15678
  DestroyImage(flip_image);
15132
15679
  CHECK_EXCEPTION();
15133
15680
 
15134
15681
 
15135
15682
  #if defined(IMAGEMAGICK_7)
15136
- SetImageStorageClass(reflection, DirectClass, exception);
15683
+ GVL_STRUCT_TYPE(SetImageStorageClass) args_SetImageStorageClass = { reflection, DirectClass, exception };
15684
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args_SetImageStorageClass);
15137
15685
  rm_check_exception(exception, reflection, DestroyOnError);
15138
- SetImageAlphaChannel(reflection, ActivateAlphaChannel, exception);
15686
+ GVL_STRUCT_TYPE(SetImageAlphaChannel) args_SetImageAlphaChannel = { reflection, ActivateAlphaChannel, exception };
15687
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageAlphaChannel), &args_SetImageAlphaChannel);
15139
15688
  rm_check_exception(exception, reflection, DestroyOnError);
15140
15689
  #else
15141
- SetImageStorageClass(reflection, DirectClass);
15690
+ GVL_STRUCT_TYPE(SetImageStorageClass) args_SetImageStorageClass = { reflection, DirectClass };
15691
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args_SetImageStorageClass);
15142
15692
  rm_check_image_exception(reflection, DestroyOnError);
15143
15693
 
15144
15694
 
@@ -15160,7 +15710,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15160
15710
  }
15161
15711
  #endif
15162
15712
 
15163
- p = GetVirtualPixels(reflection, 0, y, image->columns, 1, exception);
15713
+ GVL_STRUCT_TYPE(GetVirtualPixels) args_GetVirtualPixels = { reflection, 0, y, image->columns, 1, exception };
15714
+ p = CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetVirtualPixels), &args_GetVirtualPixels);
15164
15715
  rm_check_exception(exception, reflection, DestroyOnError);
15165
15716
  if (!p)
15166
15717
  {
@@ -15192,8 +15743,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15192
15743
  #endif
15193
15744
  }
15194
15745
 
15195
-
15196
- SyncAuthenticPixels(reflection, exception);
15746
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args_SyncAuthenticPixels = { reflection, exception };
15747
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args_SyncAuthenticPixels);
15197
15748
  rm_check_exception(exception, reflection, DestroyOnError);
15198
15749
 
15199
15750
  opacity += step;
@@ -15226,7 +15777,7 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15226
15777
  VALUE
15227
15778
  Image_white_threshold(int argc, VALUE *argv, VALUE self)
15228
15779
  {
15229
- return threshold_image(argc, argv, self, WhiteThresholdImage);
15780
+ return threshold_image(argc, argv, self, GVL_FUNC(WhiteThresholdImage));
15230
15781
  }
15231
15782
 
15232
15783
 
@@ -15253,6 +15804,10 @@ void add_format_prefix(Info *info, VALUE file)
15253
15804
  char *p;
15254
15805
 
15255
15806
  // Convert arg to string. If an exception occurs raise an error condition.
15807
+ if (rb_respond_to(file, rb_intern("path")))
15808
+ {
15809
+ FilePathStringValue(file);
15810
+ }
15256
15811
  file = rb_rescue(rb_String, file, file_arg_rescue, file);
15257
15812
 
15258
15813
  filename = rm_str2cstr(file, &filename_l);
@@ -15339,7 +15894,7 @@ Image_write(VALUE self, VALUE file)
15339
15894
  image = rm_check_destroyed(self);
15340
15895
 
15341
15896
  info_obj = rm_info_new();
15342
- Data_Get_Struct(info_obj, Info, info);
15897
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
15343
15898
 
15344
15899
  if (TYPE(file) == T_FILE)
15345
15900
  {
@@ -15348,32 +15903,32 @@ Image_write(VALUE self, VALUE file)
15348
15903
  // Ensure file is open - raise error if not
15349
15904
  GetOpenFile(file, fptr);
15350
15905
  rb_io_check_writable(fptr);
15351
- #if defined(_WIN32)
15352
15906
  add_format_prefix(info, fptr->pathv);
15353
- strlcpy(image->filename, info->filename, sizeof(image->filename));
15907
+ #if defined(_WIN32)
15354
15908
  SetImageInfoFile(info, NULL);
15355
15909
  #else
15356
15910
  SetImageInfoFile(info, rb_io_stdio_file(fptr));
15357
- memset(image->filename, 0, sizeof(image->filename));
15358
15911
  #endif
15359
15912
  }
15360
15913
  else
15361
15914
  {
15362
15915
  add_format_prefix(info, file);
15363
- strlcpy(image->filename, info->filename, sizeof(image->filename));
15364
15916
  SetImageInfoFile(info, NULL);
15365
15917
  }
15918
+ strlcpy(image->filename, info->filename, sizeof(image->filename));
15366
15919
 
15367
15920
  rm_sync_image_options(image, info);
15368
15921
 
15369
15922
  info->adjoin = MagickFalse;
15370
15923
  #if defined(IMAGEMAGICK_7)
15371
15924
  exception = AcquireExceptionInfo();
15372
- WriteImage(info, image, exception);
15925
+ GVL_STRUCT_TYPE(WriteImage) args = { info, image, exception };
15926
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WriteImage), &args);
15373
15927
  CHECK_EXCEPTION();
15374
15928
  DestroyExceptionInfo(exception);
15375
15929
  #else
15376
- WriteImage(info, image);
15930
+ GVL_STRUCT_TYPE(WriteImage) args = { info, image };
15931
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WriteImage), &args);
15377
15932
  rm_check_image_exception(image, RetainOnError);
15378
15933
  #endif
15379
15934
 
@@ -15391,7 +15946,7 @@ Image_write(VALUE self, VALUE file)
15391
15946
  VALUE
15392
15947
  Image_x_resolution(VALUE self)
15393
15948
  {
15394
- IMPLEMENT_ATTR_READERF(Image, x_resolution, resolution.x, dbl);
15949
+ IMPLEMENT_TYPED_ATTR_READERF(Image, x_resolution, resolution.x, dbl, &rm_image_data_type);
15395
15950
  }
15396
15951
 
15397
15952
  /**
@@ -15403,7 +15958,7 @@ Image_x_resolution(VALUE self)
15403
15958
  VALUE
15404
15959
  Image_x_resolution_eq(VALUE self, VALUE val)
15405
15960
  {
15406
- IMPLEMENT_ATTR_WRITERF(Image, x_resolution, resolution.x, dbl);
15961
+ IMPLEMENT_TYPED_ATTR_WRITERF(Image, x_resolution, resolution.x, dbl, &rm_image_data_type);
15407
15962
  }
15408
15963
 
15409
15964
  /**
@@ -15414,7 +15969,7 @@ Image_x_resolution_eq(VALUE self, VALUE val)
15414
15969
  VALUE
15415
15970
  Image_y_resolution(VALUE self)
15416
15971
  {
15417
- IMPLEMENT_ATTR_READERF(Image, y_resolution, resolution.y, dbl);
15972
+ IMPLEMENT_TYPED_ATTR_READERF(Image, y_resolution, resolution.y, dbl, &rm_image_data_type);
15418
15973
  }
15419
15974
 
15420
15975
  /**
@@ -15426,7 +15981,7 @@ Image_y_resolution(VALUE self)
15426
15981
  VALUE
15427
15982
  Image_y_resolution_eq(VALUE self, VALUE val)
15428
15983
  {
15429
- IMPLEMENT_ATTR_WRITERF(Image, y_resolution, resolution.y, dbl);
15984
+ IMPLEMENT_TYPED_ATTR_WRITERF(Image, y_resolution, resolution.y, dbl, &rm_image_data_type);
15430
15985
  }
15431
15986
  #else
15432
15987
  /**
@@ -15437,7 +15992,7 @@ Image_y_resolution_eq(VALUE self, VALUE val)
15437
15992
  VALUE
15438
15993
  Image_x_resolution(VALUE self)
15439
15994
  {
15440
- IMPLEMENT_ATTR_READER(Image, x_resolution, dbl);
15995
+ IMPLEMENT_TYPED_ATTR_READER(Image, x_resolution, dbl, &rm_image_data_type);
15441
15996
  }
15442
15997
 
15443
15998
  /**
@@ -15449,7 +16004,7 @@ Image_x_resolution(VALUE self)
15449
16004
  VALUE
15450
16005
  Image_x_resolution_eq(VALUE self, VALUE val)
15451
16006
  {
15452
- IMPLEMENT_ATTR_WRITER(Image, x_resolution, dbl);
16007
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, x_resolution, dbl, &rm_image_data_type);
15453
16008
  }
15454
16009
 
15455
16010
  /**
@@ -15460,7 +16015,7 @@ Image_x_resolution_eq(VALUE self, VALUE val)
15460
16015
  VALUE
15461
16016
  Image_y_resolution(VALUE self)
15462
16017
  {
15463
- IMPLEMENT_ATTR_READER(Image, y_resolution, dbl);
16018
+ IMPLEMENT_TYPED_ATTR_READER(Image, y_resolution, dbl, &rm_image_data_type);
15464
16019
  }
15465
16020
 
15466
16021
  /**
@@ -15472,7 +16027,7 @@ Image_y_resolution(VALUE self)
15472
16027
  VALUE
15473
16028
  Image_y_resolution_eq(VALUE self, VALUE val)
15474
16029
  {
15475
- IMPLEMENT_ATTR_WRITER(Image, y_resolution, dbl);
16030
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, y_resolution, dbl, &rm_image_data_type);
15476
16031
  }
15477
16032
  #endif
15478
16033
 
@@ -15531,7 +16086,7 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15531
16086
  switch (argc)
15532
16087
  {
15533
16088
  case 5:
15534
- Data_Get_Struct(self, Image, image);
16089
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
15535
16090
 
15536
16091
  VALUE_TO_ENUM(argv[0], gravity, GravityType);
15537
16092
 
@@ -15598,7 +16153,7 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15598
16153
  columns = NUM2ULONG(width);
15599
16154
  rows = NUM2ULONG(height);
15600
16155
 
15601
- Data_Get_Struct(self, Image, image);
16156
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
15602
16157
 
15603
16158
  switch (gravity)
15604
16159
  {
@@ -15661,10 +16216,10 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15661
16216
  break;
15662
16217
  }
15663
16218
 
15664
- cropped = xform_image(bang, self, x, y, width, height, CropImage);
16219
+ cropped = xform_image(bang, self, x, y, width, height, GVL_FUNC(CropImage));
15665
16220
  if (reset_page)
15666
16221
  {
15667
- Data_Get_Struct(cropped, Image, image);
16222
+ TypedData_Get_Struct(cropped, Image, &rm_image_data_type, image);
15668
16223
  ResetImagePage(image, "0x0+0+0");
15669
16224
  }
15670
16225
 
@@ -15677,6 +16232,9 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15677
16232
  }
15678
16233
 
15679
16234
 
16235
+ // aliases for common use of structure types; ChopImage, CropImage, ShaveImage
16236
+ typedef GVL_STRUCT_TYPE(ChopImage) GVL_STRUCT_TYPE(xform_image);
16237
+
15680
16238
  /**
15681
16239
  * Call one of the image transformation functions.
15682
16240
  *
@@ -15692,13 +16250,13 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15692
16250
  * @return self if bang, otherwise a new image
15693
16251
  */
15694
16252
  static VALUE
15695
- xform_image(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, xformer_t xformer)
16253
+ xform_image(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, gvl_function_t fp)
15696
16254
  {
15697
16255
  Image *image, *new_image;
15698
16256
  RectangleInfo rect;
15699
16257
  ExceptionInfo *exception;
15700
16258
 
15701
- Data_Get_Struct(self, Image, image);
16259
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
15702
16260
  rect.x = NUM2LONG(x);
15703
16261
  rect.y = NUM2LONG(y);
15704
16262
  rect.width = NUM2ULONG(width);
@@ -15706,7 +16264,8 @@ xform_image(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, x
15706
16264
 
15707
16265
  exception = AcquireExceptionInfo();
15708
16266
 
15709
- new_image = (xformer)(image, &rect, exception);
16267
+ GVL_STRUCT_TYPE(xform_image) args = { image, &rect, exception };
16268
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
15710
16269
 
15711
16270
  // An exception can occur in either the old or the new images
15712
16271
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -15792,75 +16351,6 @@ raise_ChannelType_error(VALUE arg)
15792
16351
  }
15793
16352
 
15794
16353
 
15795
-
15796
- /**
15797
- * If Magick.trace_proc is not nil, build an argument list and call the proc.
15798
- *
15799
- * No Ruby usage (internal function)
15800
- *
15801
- * @param image the image
15802
- * @param which which operation the proc is being called for
15803
- */
15804
- static void call_trace_proc(Image *image, const char *which)
15805
- {
15806
- VALUE trace;
15807
- VALUE trace_args[4];
15808
-
15809
- if (rb_ivar_defined(Module_Magick, rm_ID_trace_proc) == Qtrue)
15810
- {
15811
- trace = rb_ivar_get(Module_Magick, rm_ID_trace_proc);
15812
- if (!NIL_P(trace))
15813
- {
15814
- // Maybe the stack won't get extended until we need the space.
15815
- char buffer[MaxTextExtent];
15816
-
15817
- trace_args[0] = ID2SYM(rb_intern(which));
15818
-
15819
- build_inspect_string(image, buffer, sizeof(buffer));
15820
- trace_args[1] = rb_str_new2(buffer);
15821
-
15822
- snprintf(buffer, sizeof(buffer), "%p", (void *)image);
15823
- trace_args[2] = rb_str_new2(buffer+2); // don't use leading 0x
15824
- trace_args[3] = ID2SYM(rb_frame_this_func());
15825
- rb_funcall2(trace, rm_ID_call, 4, (VALUE *)trace_args);
15826
- }
15827
- }
15828
-
15829
- RB_GC_GUARD(trace);
15830
- }
15831
-
15832
-
15833
- static VALUE
15834
- rm_trace_creation_body(VALUE img)
15835
- {
15836
- Image *image = (Image *)img;
15837
- call_trace_proc(image, "c");
15838
- return Qnil;
15839
- }
15840
-
15841
- static VALUE
15842
- rm_trace_creation_handle_exception(VALUE img, VALUE exc)
15843
- {
15844
- Image *image = (Image *)img;
15845
- DestroyImage(image);
15846
- rb_exc_raise(exc);
15847
- }
15848
-
15849
- /**
15850
- * Trace image creation
15851
- *
15852
- * No Ruby usage (internal function)
15853
- *
15854
- * @param image the image
15855
- * @see call_trace_proc
15856
- */
15857
- void rm_trace_creation(Image *image)
15858
- {
15859
- rb_rescue(rm_trace_creation_body, (VALUE)image, rm_trace_creation_handle_exception, (VALUE)image);
15860
- }
15861
-
15862
-
15863
-
15864
16354
  /**
15865
16355
  * Destroy an image. Called from GC when all references to the image have gone
15866
16356
  * out of scope.
@@ -15879,9 +16369,19 @@ void rm_image_destroy(void *img)
15879
16369
 
15880
16370
  if (img != NULL)
15881
16371
  {
15882
- call_trace_proc(image, "d");
15883
16372
  DestroyImage(image);
15884
16373
  }
15885
16374
  }
15886
16375
 
15887
-
16376
+ /**
16377
+ * Get Image object size.
16378
+ *
16379
+ * No Ruby usage (internal function)
16380
+ *
16381
+ * @param ptr pointer to the Image object
16382
+ */
16383
+ static size_t
16384
+ rm_image_memsize(const void *ptr)
16385
+ {
16386
+ return sizeof(Image);
16387
+ }