rmagick 4.3.0 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of rmagick might be problematic. Click here for more details.

@@ -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
 
@@ -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
 
@@ -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
 
@@ -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
 
@@ -5043,11 +5368,13 @@ Image_delete_profile(VALUE self, VALUE name)
5043
5368
  #if defined(IMAGEMAGICK_7)
5044
5369
  ExceptionInfo *exception = AcquireExceptionInfo();
5045
5370
 
5046
- ProfileImage(image, StringValueCStr(name), NULL, 0, exception);
5371
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, StringValueCStr(name), NULL, 0, exception };
5372
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
5047
5373
  CHECK_EXCEPTION();
5048
5374
  DestroyExceptionInfo(exception);
5049
5375
  #else
5050
- ProfileImage(image, StringValueCStr(name), NULL, 0, MagickTrue);
5376
+ GVL_STRUCT_TYPE(ProfileImage) args = { image, StringValueCStr(name), NULL, 0, MagickTrue };
5377
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ProfileImage), &args);
5051
5378
  #endif
5052
5379
  return self;
5053
5380
  }
@@ -5065,13 +5392,14 @@ VALUE
5065
5392
  Image_depth(VALUE self)
5066
5393
  {
5067
5394
  Image *image;
5068
- unsigned long depth = 0;
5395
+ size_t depth = 0;
5069
5396
  ExceptionInfo *exception;
5070
5397
 
5071
5398
  image = rm_check_destroyed(self);
5072
5399
  exception = AcquireExceptionInfo();
5073
5400
 
5074
- depth = GetImageDepth(image, exception);
5401
+ GVL_STRUCT_TYPE(GetImageDepth) args = { image, exception };
5402
+ depth = (size_t)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageDepth), &args);
5075
5403
  CHECK_EXCEPTION();
5076
5404
 
5077
5405
  DestroyExceptionInfo(exception);
@@ -5118,7 +5446,8 @@ Image_deskew(int argc, VALUE *argv, VALUE self)
5118
5446
  }
5119
5447
 
5120
5448
  exception = AcquireExceptionInfo();
5121
- 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);
5122
5451
  CHECK_EXCEPTION();
5123
5452
  DestroyExceptionInfo(exception);
5124
5453
 
@@ -5140,7 +5469,8 @@ Image_despeckle(VALUE self)
5140
5469
  image = rm_check_destroyed(self);
5141
5470
  exception = AcquireExceptionInfo();
5142
5471
 
5143
- 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);
5144
5474
  rm_check_exception(exception, new_image, DestroyOnError);
5145
5475
  DestroyExceptionInfo(exception);
5146
5476
 
@@ -5159,7 +5489,7 @@ Image_destroy_bang(VALUE self)
5159
5489
  Image *image;
5160
5490
 
5161
5491
  rb_check_frozen(self);
5162
- Data_Get_Struct(self, Image, image);
5492
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
5163
5493
  rm_image_destroy(image);
5164
5494
  DATA_PTR(self) = NULL;
5165
5495
  return self;
@@ -5176,7 +5506,7 @@ Image_destroyed_q(VALUE self)
5176
5506
  {
5177
5507
  Image *image;
5178
5508
 
5179
- Data_Get_Struct(self, Image, image);
5509
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
5180
5510
  return image ? Qfalse : Qtrue;
5181
5511
  }
5182
5512
 
@@ -5215,11 +5545,13 @@ Image_difference(VALUE self, VALUE other)
5215
5545
 
5216
5546
  #if defined(IMAGEMAGICK_7)
5217
5547
  exception = AcquireExceptionInfo();
5218
- GetImageDistortion(image, image2, MeanErrorPerPixelErrorMetric, &distortion, exception);
5548
+ GVL_STRUCT_TYPE(GetImageDistortion) args = { image, image2, MeanErrorPerPixelErrorMetric, &distortion, exception };
5549
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageDistortion), &args);
5219
5550
  CHECK_EXCEPTION();
5220
5551
  DestroyExceptionInfo(exception);
5221
5552
  #else
5222
- IsImagesEqual(image, image2);
5553
+ GVL_STRUCT_TYPE(IsImagesEqual) args = { image, image2 };
5554
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(IsImagesEqual), &args);
5223
5555
  rm_check_image_exception(image, RetainOnError);
5224
5556
  #endif
5225
5557
 
@@ -5243,7 +5575,7 @@ Image_difference(VALUE self, VALUE other)
5243
5575
  VALUE
5244
5576
  Image_directory(VALUE self)
5245
5577
  {
5246
- IMPLEMENT_ATTR_READER(Image, directory, str);
5578
+ IMPLEMENT_TYPED_ATTR_READER(Image, directory, str, &rm_image_data_type);
5247
5579
  }
5248
5580
 
5249
5581
 
@@ -5368,10 +5700,11 @@ Image_dispatch(int argc, VALUE *argv, VALUE self)
5368
5700
  // Create the Ruby array for the pixels. Return this even if ExportImagePixels fails.
5369
5701
  pixels_ary = rb_ary_new();
5370
5702
 
5371
- Data_Get_Struct(self, Image, image);
5703
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
5372
5704
 
5373
5705
  exception = AcquireExceptionInfo();
5374
- 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);
5375
5708
 
5376
5709
  if (!okay)
5377
5710
  {
@@ -5430,7 +5763,7 @@ Image_display(VALUE self)
5430
5763
  }
5431
5764
 
5432
5765
  info_obj = rm_info_new();
5433
- Data_Get_Struct(info_obj, Info, info);
5766
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
5434
5767
 
5435
5768
  #if defined(IMAGEMAGICK_7)
5436
5769
  exception = AcquireExceptionInfo();
@@ -5633,7 +5966,8 @@ Image_distort(int argc, VALUE *argv, VALUE self)
5633
5966
  }
5634
5967
 
5635
5968
  exception = AcquireExceptionInfo();
5636
- 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);
5637
5971
  xfree(points);
5638
5972
  rm_check_exception(exception, new_image, DestroyOnError);
5639
5973
  DestroyExceptionInfo(exception);
@@ -5692,11 +6026,13 @@ Image_distortion_channel(int argc, VALUE *argv, VALUE self)
5692
6026
  exception = AcquireExceptionInfo();
5693
6027
  #if defined(IMAGEMAGICK_7)
5694
6028
  BEGIN_CHANNEL_MASK(image, channels);
5695
- 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);
5696
6031
  END_CHANNEL_MASK(image);
5697
6032
  DestroyImage(difference_image);
5698
6033
  #else
5699
- 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);
5700
6036
  #endif
5701
6037
 
5702
6038
  CHECK_EXCEPTION();
@@ -5736,7 +6072,8 @@ Image__dump(VALUE self, VALUE depth ATTRIBUTE_UNUSED)
5736
6072
  strlcpy(info->magick, image->magick, sizeof(info->magick));
5737
6073
 
5738
6074
  exception = AcquireExceptionInfo();
5739
- 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);
5740
6077
 
5741
6078
  // Free ImageInfo first - error handling may raise an exception
5742
6079
  DestroyImageInfo(info);
@@ -5782,7 +6119,7 @@ Image_dup(VALUE self)
5782
6119
  VALUE dup;
5783
6120
 
5784
6121
  rm_check_destroyed(self);
5785
- 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);
5786
6123
  RB_GC_GUARD(dup);
5787
6124
 
5788
6125
  return rb_funcall(dup, rm_ID_initialize_copy, 1, self);
@@ -5864,7 +6201,8 @@ Image_edge(int argc, VALUE *argv, VALUE self)
5864
6201
 
5865
6202
  exception = AcquireExceptionInfo();
5866
6203
 
5867
- 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);
5868
6206
  rm_check_exception(exception, new_image, DestroyOnError);
5869
6207
  DestroyExceptionInfo(exception);
5870
6208
 
@@ -5872,6 +6210,9 @@ Image_edge(int argc, VALUE *argv, VALUE self)
5872
6210
  }
5873
6211
 
5874
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
+
5875
6216
  /**
5876
6217
  * Call one of the effects methods.
5877
6218
  *
@@ -5884,7 +6225,7 @@ Image_edge(int argc, VALUE *argv, VALUE self)
5884
6225
  * @return a new image
5885
6226
  */
5886
6227
  static VALUE
5887
- effect_image(VALUE self, int argc, VALUE *argv, effector_t effector)
6228
+ effect_image(VALUE self, int argc, VALUE *argv, gvl_function_t fp)
5888
6229
  {
5889
6230
  Image *image, *new_image;
5890
6231
  ExceptionInfo *exception;
@@ -5911,7 +6252,8 @@ effect_image(VALUE self, int argc, VALUE *argv, effector_t effector)
5911
6252
  }
5912
6253
 
5913
6254
  exception = AcquireExceptionInfo();
5914
- 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);
5915
6257
  rm_check_exception(exception, new_image, DestroyOnError);
5916
6258
  DestroyExceptionInfo(exception);
5917
6259
 
@@ -5930,7 +6272,7 @@ effect_image(VALUE self, int argc, VALUE *argv, effector_t effector)
5930
6272
  VALUE
5931
6273
  Image_emboss(int argc, VALUE *argv, VALUE self)
5932
6274
  {
5933
- return effect_image(self, argc, argv, EmbossImage);
6275
+ return effect_image(self, argc, argv, GVL_FUNC(EmbossImage));
5934
6276
  }
5935
6277
 
5936
6278
 
@@ -5956,7 +6298,8 @@ Image_encipher(VALUE self, VALUE passphrase)
5956
6298
 
5957
6299
  new_image = rm_clone_image(image);
5958
6300
 
5959
- 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);
5960
6303
  rm_check_exception(exception, new_image, DestroyOnError);
5961
6304
  if (!okay)
5962
6305
  {
@@ -6012,7 +6355,8 @@ Image_enhance(VALUE self)
6012
6355
  image = rm_check_destroyed(self);
6013
6356
  exception = AcquireExceptionInfo();
6014
6357
 
6015
- 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);
6016
6360
  rm_check_exception(exception, new_image, DestroyOnError);
6017
6361
  DestroyExceptionInfo(exception);
6018
6362
 
@@ -6038,11 +6382,13 @@ Image_equalize(VALUE self)
6038
6382
 
6039
6383
  #if defined(IMAGEMAGICK_7)
6040
6384
  exception = AcquireExceptionInfo();
6041
- EqualizeImage(new_image, exception);
6385
+ GVL_STRUCT_TYPE(EqualizeImage) args = { new_image, exception };
6386
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImage), &args);
6042
6387
  rm_check_exception(exception, new_image, DestroyOnError);
6043
6388
  DestroyExceptionInfo(exception);
6044
6389
  #else
6045
- EqualizeImage(new_image);
6390
+ GVL_STRUCT_TYPE(EqualizeImage) args = { new_image };
6391
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImage), &args);
6046
6392
  rm_check_image_exception(new_image, DestroyOnError);
6047
6393
  #endif
6048
6394
 
@@ -6082,12 +6428,14 @@ Image_equalize_channel(int argc, VALUE *argv, VALUE self)
6082
6428
  #if defined(IMAGEMAGICK_7)
6083
6429
  exception = AcquireExceptionInfo();
6084
6430
  BEGIN_CHANNEL_MASK(new_image, channels);
6085
- EqualizeImage(new_image, exception);
6431
+ GVL_STRUCT_TYPE(EqualizeImage) args = { new_image, exception };
6432
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImage), &args);
6086
6433
  END_CHANNEL_MASK(new_image);
6087
6434
  rm_check_exception(exception, new_image, DestroyOnError);
6088
6435
  DestroyExceptionInfo(exception);
6089
6436
  #else
6090
- EqualizeImageChannel(new_image, channels);
6437
+ GVL_STRUCT_TYPE(EqualizeImageChannel) args = { new_image, channels };
6438
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EqualizeImageChannel), &args);
6091
6439
 
6092
6440
  rm_check_image_exception(new_image, DestroyOnError);
6093
6441
  #endif
@@ -6113,11 +6461,13 @@ Image_erase_bang(VALUE self)
6113
6461
 
6114
6462
  #if defined(IMAGEMAGICK_7)
6115
6463
  exception = AcquireExceptionInfo();
6116
- SetImageBackgroundColor(image, exception);
6464
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image, exception };
6465
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
6117
6466
  CHECK_EXCEPTION();
6118
6467
  DestroyExceptionInfo(exception);
6119
6468
  #else
6120
- SetImageBackgroundColor(image);
6469
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image };
6470
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
6121
6471
  rm_check_image_exception(image, RetainOnError);
6122
6472
  #endif
6123
6473
 
@@ -6159,10 +6509,11 @@ excerpt(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height)
6159
6509
  rect.width = NUM2ULONG(width);
6160
6510
  rect.height = NUM2ULONG(height);
6161
6511
 
6162
- Data_Get_Struct(self, Image, image);
6512
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
6163
6513
 
6164
6514
  exception = AcquireExceptionInfo();
6165
- 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);
6166
6517
  rm_check_exception(exception, new_image, DestroyOnError);
6167
6518
  DestroyExceptionInfo(exception);
6168
6519
 
@@ -6250,7 +6601,7 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
6250
6601
  long x_off = 0L, y_off = 0L;
6251
6602
  unsigned long cols, rows;
6252
6603
  long n, npixels;
6253
- unsigned int okay;
6604
+ MagickBooleanType okay;
6254
6605
  const char *map = "RGB";
6255
6606
  Quantum *pixels;
6256
6607
  VALUE ary;
@@ -6297,7 +6648,8 @@ Image_export_pixels(int argc, VALUE *argv, VALUE self)
6297
6648
 
6298
6649
  exception = AcquireExceptionInfo();
6299
6650
 
6300
- 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);
6301
6653
  if (!okay)
6302
6654
  {
6303
6655
  xfree((void *)pixels);
@@ -6379,10 +6731,11 @@ Image_extent(int argc, VALUE *argv, VALUE self)
6379
6731
  }
6380
6732
 
6381
6733
 
6382
- Data_Get_Struct(self, Image, image);
6734
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
6383
6735
  exception = AcquireExceptionInfo();
6384
6736
 
6385
- 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);
6386
6739
  rm_check_exception(exception, new_image, DestroyOnError);
6387
6740
  DestroyExceptionInfo(exception);
6388
6741
 
@@ -6414,7 +6767,7 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6414
6767
  unsigned long cols, rows;
6415
6768
  unsigned long npixels;
6416
6769
  size_t sz;
6417
- unsigned int okay;
6770
+ MagickBooleanType okay;
6418
6771
  const char *map = "RGB";
6419
6772
  StorageType type = CharPixel;
6420
6773
  VALUE string;
@@ -6487,7 +6840,8 @@ Image_export_pixels_to_str(int argc, VALUE *argv, VALUE self)
6487
6840
 
6488
6841
  exception = AcquireExceptionInfo();
6489
6842
 
6490
- 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);
6491
6845
  if (!okay)
6492
6846
  {
6493
6847
  // Let GC have the string buffer.
@@ -6542,7 +6896,7 @@ Image_extract_info_eq(VALUE self, VALUE rect)
6542
6896
  VALUE
6543
6897
  Image_filename(VALUE self)
6544
6898
  {
6545
- IMPLEMENT_ATTR_READER(Image, filename, str);
6899
+ IMPLEMENT_TYPED_ATTR_READER(Image, filename, str, &rm_image_data_type);
6546
6900
  }
6547
6901
 
6548
6902
 
@@ -6609,7 +6963,7 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6609
6963
  VALUE region, targ;
6610
6964
  ssize_t x = 0L, y = 0L;
6611
6965
  ExceptionInfo *exception;
6612
- unsigned int okay;
6966
+ MagickBooleanType okay;
6613
6967
 
6614
6968
  image = rm_check_destroyed(self);
6615
6969
 
@@ -6629,7 +6983,13 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6629
6983
  }
6630
6984
 
6631
6985
  exception = AcquireExceptionInfo();
6632
- 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
6633
6993
  CHECK_EXCEPTION();
6634
6994
  DestroyExceptionInfo(exception);
6635
6995
 
@@ -6649,6 +7009,9 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6649
7009
  }
6650
7010
 
6651
7011
 
7012
+ // aliases for common use of structure types; FlopImage, FlipImage
7013
+ typedef GVL_STRUCT_TYPE(FlipImage) GVL_STRUCT_TYPE(flipflop);
7014
+
6652
7015
  /**
6653
7016
  * Call a flipflopper (a function that either flips or flops the image).
6654
7017
  *
@@ -6664,15 +7027,16 @@ Image_find_similar_region(int argc, VALUE *argv, VALUE self)
6664
7027
  * @see Image_flop_bang
6665
7028
  */
6666
7029
  static VALUE
6667
- flipflop(int bang, VALUE self, flipper_t flipflopper)
7030
+ flipflop(int bang, VALUE self, gvl_function_t fp)
6668
7031
  {
6669
7032
  Image *image, *new_image;
6670
7033
  ExceptionInfo *exception;
6671
7034
 
6672
- Data_Get_Struct(self, Image, image);
7035
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
6673
7036
  exception = AcquireExceptionInfo();
6674
7037
 
6675
- new_image = (flipflopper)(image, exception);
7038
+ GVL_STRUCT_TYPE(flipflop) args = { image, exception };
7039
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
6676
7040
  rm_check_exception(exception, new_image, DestroyOnError);
6677
7041
  DestroyExceptionInfo(exception);
6678
7042
 
@@ -6700,7 +7064,7 @@ VALUE
6700
7064
  Image_flip(VALUE self)
6701
7065
  {
6702
7066
  rm_check_destroyed(self);
6703
- return flipflop(False, self, FlipImage);
7067
+ return flipflop(False, self, GVL_FUNC(FlipImage));
6704
7068
  }
6705
7069
 
6706
7070
 
@@ -6717,7 +7081,7 @@ VALUE
6717
7081
  Image_flip_bang(VALUE self)
6718
7082
  {
6719
7083
  rm_check_frozen(self);
6720
- return flipflop(True, self, FlipImage);
7084
+ return flipflop(True, self, GVL_FUNC(FlipImage));
6721
7085
  }
6722
7086
 
6723
7087
 
@@ -6733,7 +7097,7 @@ VALUE
6733
7097
  Image_flop(VALUE self)
6734
7098
  {
6735
7099
  rm_check_destroyed(self);
6736
- return flipflop(False, self, FlopImage);
7100
+ return flipflop(False, self, GVL_FUNC(FlopImage));
6737
7101
  }
6738
7102
 
6739
7103
 
@@ -6750,7 +7114,7 @@ VALUE
6750
7114
  Image_flop_bang(VALUE self)
6751
7115
  {
6752
7116
  rm_check_frozen(self);
6753
- return flipflop(True, self, FlopImage);
7117
+ return flipflop(True, self, GVL_FUNC(FlopImage));
6754
7118
  }
6755
7119
 
6756
7120
 
@@ -6870,10 +7234,11 @@ Image_frame(int argc, VALUE *argv, VALUE self)
6870
7234
 
6871
7235
  exception = AcquireExceptionInfo();
6872
7236
  #if defined(IMAGEMAGICK_7)
6873
- new_image = FrameImage(image, &frame_info, image->compose, exception);
7237
+ GVL_STRUCT_TYPE(FrameImage) args = { image, &frame_info, image->compose, exception };
6874
7238
  #else
6875
- new_image = FrameImage(image, &frame_info, exception);
7239
+ GVL_STRUCT_TYPE(FrameImage) args = { image, &frame_info, exception };
6876
7240
  #endif
7241
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(FrameImage), &args);
6877
7242
  rm_check_exception(exception, new_image, DestroyOnError);
6878
7243
  DestroyExceptionInfo(exception);
6879
7244
 
@@ -6909,10 +7274,11 @@ Image_from_blob(VALUE class ATTRIBUTE_UNUSED, VALUE blob_arg)
6909
7274
 
6910
7275
  // Get a new Info object - run the parm block if supplied
6911
7276
  info_obj = rm_info_new();
6912
- Data_Get_Struct(info_obj, Info, info);
7277
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
6913
7278
 
6914
7279
  exception = AcquireExceptionInfo();
6915
- 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);
6916
7282
  rm_check_exception(exception, images, DestroyOnError);
6917
7283
 
6918
7284
  DestroyExceptionInfo(exception);
@@ -7012,10 +7378,12 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
7012
7378
  new_image = rm_clone_image(image);
7013
7379
  #if defined(IMAGEMAGICK_7)
7014
7380
  BEGIN_CHANNEL_MASK(new_image, channels);
7015
- 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);
7016
7383
  END_CHANNEL_MASK(new_image);
7017
7384
  #else
7018
- 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);
7019
7387
  #endif
7020
7388
  xfree(parms);
7021
7389
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -7036,7 +7404,7 @@ Image_function_channel(int argc, VALUE *argv, VALUE self)
7036
7404
  VALUE
7037
7405
  Image_fuzz(VALUE self)
7038
7406
  {
7039
- IMPLEMENT_ATTR_READER(Image, fuzz, dbl);
7407
+ IMPLEMENT_TYPED_ATTR_READER(Image, fuzz, dbl, &rm_image_data_type);
7040
7408
  }
7041
7409
 
7042
7410
 
@@ -7096,11 +7464,13 @@ Image_fx(int argc, VALUE *argv, VALUE self)
7096
7464
  exception = AcquireExceptionInfo();
7097
7465
  #if defined(IMAGEMAGICK_7)
7098
7466
  BEGIN_CHANNEL_MASK(image, channels);
7099
- 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);
7100
7469
  CHANGE_RESULT_CHANNEL_MASK(new_image);
7101
7470
  END_CHANNEL_MASK(image);
7102
7471
  #else
7103
- 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);
7104
7474
  #endif
7105
7475
  rm_check_exception(exception, new_image, DestroyOnError);
7106
7476
  DestroyExceptionInfo(exception);
@@ -7116,7 +7486,7 @@ Image_fx(int argc, VALUE *argv, VALUE self)
7116
7486
  VALUE
7117
7487
  Image_gamma(VALUE self)
7118
7488
  {
7119
- IMPLEMENT_ATTR_READER(Image, gamma, dbl);
7489
+ IMPLEMENT_TYPED_ATTR_READER(Image, gamma, dbl, &rm_image_data_type);
7120
7490
  }
7121
7491
 
7122
7492
  /**
@@ -7128,7 +7498,7 @@ Image_gamma(VALUE self)
7128
7498
  VALUE
7129
7499
  Image_gamma_eq(VALUE self, VALUE val)
7130
7500
  {
7131
- IMPLEMENT_ATTR_WRITER(Image, gamma, dbl);
7501
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, gamma, dbl, &rm_image_data_type);
7132
7502
  }
7133
7503
 
7134
7504
 
@@ -7176,12 +7546,14 @@ Image_gamma_channel(int argc, VALUE *argv, VALUE self)
7176
7546
  #if defined(IMAGEMAGICK_7)
7177
7547
  exception = AcquireExceptionInfo();
7178
7548
  BEGIN_CHANNEL_MASK(new_image, channels);
7179
- GammaImage(new_image, gamma, exception);
7549
+ GVL_STRUCT_TYPE(GammaImage) args = { new_image, gamma, exception };
7550
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImage), &args);
7180
7551
  END_CHANNEL_MASK(new_image);
7181
7552
  rm_check_exception(exception, new_image, DestroyOnError);
7182
7553
  DestroyExceptionInfo(exception);
7183
7554
  #else
7184
- GammaImageChannel(new_image, channels, gamma);
7555
+ GVL_STRUCT_TYPE(GammaImageChannel) args = { new_image, channels, gamma };
7556
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GammaImageChannel), &args);
7185
7557
  rm_check_image_exception(new_image, DestroyOnError);
7186
7558
  #endif
7187
7559
 
@@ -7237,30 +7609,40 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
7237
7609
  {
7238
7610
  #if defined(IMAGEMAGICK_7)
7239
7611
  BEGIN_CHANNEL_MASK(new_image, (ChannelType) (RedChannel | GreenChannel | BlueChannel));
7240
- 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);
7241
7614
  END_CHANNEL_MASK(new_image);
7242
7615
  #else
7243
- 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);
7244
7618
  #endif
7245
7619
  }
7246
7620
  else
7247
7621
  {
7248
7622
  #if defined(IMAGEMAGICK_7)
7249
7623
  BEGIN_CHANNEL_MASK(new_image, RedChannel);
7250
- 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);
7251
7626
  END_CHANNEL_MASK(new_image);
7252
7627
 
7253
7628
  BEGIN_CHANNEL_MASK(new_image, GreenChannel);
7254
- 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);
7255
7631
  END_CHANNEL_MASK(new_image);
7256
7632
 
7257
7633
  BEGIN_CHANNEL_MASK(new_image, BlueChannel);
7258
- 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);
7259
7636
  END_CHANNEL_MASK(new_image);
7260
7637
  #else
7261
- GammaImageChannel(new_image, RedChannel, red_gamma);
7262
- GammaImageChannel(new_image, GreenChannel, green_gamma);
7263
- 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);
7264
7646
  #endif
7265
7647
  }
7266
7648
 
@@ -7286,7 +7668,7 @@ Image_gamma_correct(int argc, VALUE *argv, VALUE self)
7286
7668
  VALUE
7287
7669
  Image_gaussian_blur(int argc, VALUE *argv, VALUE self)
7288
7670
  {
7289
- return effect_image(self, argc, argv, GaussianBlurImage);
7671
+ return effect_image(self, argc, argv, GVL_FUNC(GaussianBlurImage));
7290
7672
  }
7291
7673
 
7292
7674
 
@@ -7334,12 +7716,14 @@ Image_gaussian_blur_channel(int argc, VALUE *argv, VALUE self)
7334
7716
  exception = AcquireExceptionInfo();
7335
7717
  #if defined(IMAGEMAGICK_7)
7336
7718
  BEGIN_CHANNEL_MASK(image, channels);
7337
- 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);
7338
7721
  CHANGE_RESULT_CHANNEL_MASK(new_image);
7339
7722
  END_CHANNEL_MASK(image);
7340
7723
  rm_check_exception(exception, new_image, DestroyOnError);
7341
7724
  #else
7342
- 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);
7343
7727
  rm_check_exception(exception, new_image, DestroyOnError);
7344
7728
  #endif
7345
7729
 
@@ -7358,7 +7742,7 @@ Image_gaussian_blur_channel(int argc, VALUE *argv, VALUE self)
7358
7742
  VALUE
7359
7743
  Image_geometry(VALUE self)
7360
7744
  {
7361
- IMPLEMENT_ATTR_READER(Image, geometry, str);
7745
+ IMPLEMENT_TYPED_ATTR_READER(Image, geometry, str, &rm_image_data_type);
7362
7746
  }
7363
7747
 
7364
7748
 
@@ -7442,7 +7826,8 @@ Image_get_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg, VALUE row
7442
7826
  // Cast AcquireImagePixels to get rid of the const qualifier. We're not going
7443
7827
  // to change the pixels but I don't want to make "pixels" const.
7444
7828
  exception = AcquireExceptionInfo();
7445
- 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);
7446
7831
  CHECK_EXCEPTION();
7447
7832
 
7448
7833
  DestroyExceptionInfo(exception);
@@ -7619,10 +8004,11 @@ Image_implode(int argc, VALUE *argv, VALUE self)
7619
8004
  exception = AcquireExceptionInfo();
7620
8005
 
7621
8006
  #if defined(IMAGEMAGICK_7)
7622
- new_image = ImplodeImage(image, amount, image->interpolate, exception);
8007
+ GVL_STRUCT_TYPE(ImplodeImage) args = { image, amount, image->interpolate, exception };
7623
8008
  #else
7624
- new_image = ImplodeImage(image, amount, exception);
8009
+ GVL_STRUCT_TYPE(ImplodeImage) args = { image, amount, exception };
7625
8010
  #endif
8011
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImplodeImage), &args);
7626
8012
  rm_check_exception(exception, new_image, DestroyOnError);
7627
8013
  DestroyExceptionInfo(exception);
7628
8014
 
@@ -7662,7 +8048,7 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
7662
8048
  Quantum *pixels = NULL;
7663
8049
  double *fpixels = NULL;
7664
8050
  void *buffer;
7665
- unsigned int okay;
8051
+ MagickBooleanType okay;
7666
8052
  #if defined(IMAGEMAGICK_7)
7667
8053
  ExceptionInfo *exception;
7668
8054
  #endif
@@ -7799,10 +8185,11 @@ Image_import_pixels(int argc, VALUE *argv, VALUE self)
7799
8185
 
7800
8186
  #if defined(IMAGEMAGICK_7)
7801
8187
  exception = AcquireExceptionInfo();
7802
- 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 };
7803
8189
  #else
7804
- 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 };
7805
8191
  #endif
8192
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ImportImagePixels), &args);
7806
8193
 
7807
8194
  // Free pixel array before checking for errors.
7808
8195
  if (pixels)
@@ -7989,7 +8376,7 @@ Image_inspect(VALUE self)
7989
8376
  Image *image;
7990
8377
  char buffer[MaxTextExtent]; // image description buffer
7991
8378
 
7992
- Data_Get_Struct(self, Image, image);
8379
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
7993
8380
  if (!image)
7994
8381
  {
7995
8382
  return rb_str_new2("#<Magick::Image: (destroyed)>");
@@ -8082,12 +8469,12 @@ Image_iptc_profile_eq(VALUE self, VALUE profile)
8082
8469
  VALUE
8083
8470
  Image_iterations(VALUE self)
8084
8471
  {
8085
- IMPLEMENT_ATTR_READER(Image, iterations, int);
8472
+ IMPLEMENT_TYPED_ATTR_READER(Image, iterations, int, &rm_image_data_type);
8086
8473
  }
8087
8474
  VALUE
8088
8475
  Image_iterations_eq(VALUE self, VALUE val)
8089
8476
  {
8090
- IMPLEMENT_ATTR_WRITER(Image, iterations, int);
8477
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, iterations, int, &rm_image_data_type);
8091
8478
  }
8092
8479
 
8093
8480
  /**
@@ -8138,12 +8525,14 @@ Image_level2(int argc, VALUE *argv, VALUE self)
8138
8525
 
8139
8526
  #if defined(IMAGEMAGICK_7)
8140
8527
  exception = AcquireExceptionInfo();
8141
- 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);
8142
8530
  rm_check_exception(exception, new_image, DestroyOnError);
8143
8531
  DestroyExceptionInfo(exception);
8144
8532
  #else
8145
8533
  snprintf(level, sizeof(level), "%gx%g+%g", black_point, white_point, gamma_val);
8146
- LevelImage(new_image, level);
8534
+ GVL_STRUCT_TYPE(LevelImage) args = { new_image, level };
8535
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(LevelImage), &args);
8147
8536
  rm_check_image_exception(new_image, DestroyOnError);
8148
8537
  #endif
8149
8538
 
@@ -8202,12 +8591,14 @@ Image_level_channel(int argc, VALUE *argv, VALUE self)
8202
8591
  #if defined(IMAGEMAGICK_7)
8203
8592
  exception = AcquireExceptionInfo();
8204
8593
  BEGIN_CHANNEL_MASK(new_image, channel);
8205
- 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);
8206
8596
  END_CHANNEL_MASK(new_image);
8207
8597
  rm_check_exception(exception, new_image, DestroyOnError);
8208
8598
  DestroyExceptionInfo(exception);
8209
8599
  #else
8210
- 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);
8211
8602
  rm_check_image_exception(new_image, DestroyOnError);
8212
8603
  #endif
8213
8604
 
@@ -8283,12 +8674,14 @@ Image_level_colors(int argc, VALUE *argv, VALUE self)
8283
8674
  #if defined(IMAGEMAGICK_7)
8284
8675
  exception = AcquireExceptionInfo();
8285
8676
  BEGIN_CHANNEL_MASK(new_image, channels);
8286
- 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);
8287
8679
  END_CHANNEL_MASK(new_image);
8288
8680
  rm_check_exception(exception, new_image, DestroyOnError);
8289
8681
  DestroyExceptionInfo(exception);
8290
8682
  #else
8291
- 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);
8292
8685
  rm_check_image_exception(new_image, DestroyOnError);
8293
8686
  #endif
8294
8687
  if (!status)
@@ -8358,12 +8751,14 @@ Image_levelize_channel(int argc, VALUE *argv, VALUE self)
8358
8751
  #if defined(IMAGEMAGICK_7)
8359
8752
  exception = AcquireExceptionInfo();
8360
8753
  BEGIN_CHANNEL_MASK(new_image, channels);
8361
- 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);
8362
8756
  END_CHANNEL_MASK(new_image);
8363
8757
  rm_check_exception(exception, new_image, DestroyOnError);
8364
8758
  DestroyExceptionInfo(exception);
8365
8759
  #else
8366
- 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);
8367
8762
  rm_check_image_exception(new_image, DestroyOnError);
8368
8763
  #endif
8369
8764
 
@@ -8404,11 +8799,13 @@ Image_linear_stretch(int argc, VALUE *argv, VALUE self)
8404
8799
 
8405
8800
  #if defined(IMAGEMAGICK_7)
8406
8801
  exception = AcquireExceptionInfo();
8407
- 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);
8408
8804
  rm_check_exception(exception, new_image, DestroyOnError);
8409
8805
  DestroyExceptionInfo(exception);
8410
8806
  #else
8411
- 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);
8412
8809
  rm_check_image_exception(new_image, DestroyOnError);
8413
8810
  #endif
8414
8811
 
@@ -8454,7 +8851,8 @@ Image_liquid_rescale(int argc, VALUE *argv, VALUE self)
8454
8851
  }
8455
8852
 
8456
8853
  exception = AcquireExceptionInfo();
8457
- 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);
8458
8856
  rm_check_exception(exception, new_image, DestroyOnError);
8459
8857
  DestroyExceptionInfo(exception);
8460
8858
 
@@ -8522,7 +8920,8 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8522
8920
 
8523
8921
  blob += offsetof(DumpedImage, magick) + mi.len;
8524
8922
  length -= offsetof(DumpedImage, magick) + mi.len;
8525
- 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);
8526
8925
  DestroyImageInfo(info);
8527
8926
 
8528
8927
  rm_check_exception(exception, image, DestroyOnError);
@@ -8532,6 +8931,9 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8532
8931
  }
8533
8932
 
8534
8933
 
8934
+ // aliases for common use of structure types; MagnifyImage, MinifyImage
8935
+ typedef GVL_STRUCT_TYPE(MagnifyImage) GVL_STRUCT_TYPE(magnify);
8936
+
8535
8937
  /**
8536
8938
  * Scale an image proportionally to twice its size.
8537
8939
  *
@@ -8543,16 +8945,17 @@ Image__load(VALUE class ATTRIBUTE_UNUSED, VALUE str)
8543
8945
  * @return self if bang, otherwise a new image
8544
8946
  */
8545
8947
  static VALUE
8546
- magnify(int bang, VALUE self, magnifier_t magnifier)
8948
+ magnify(int bang, VALUE self, gvl_function_t fp)
8547
8949
  {
8548
8950
  Image *image;
8549
8951
  Image *new_image;
8550
8952
  ExceptionInfo *exception;
8551
8953
 
8552
- Data_Get_Struct(self, Image, image);
8954
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
8553
8955
  exception = AcquireExceptionInfo();
8554
8956
 
8555
- new_image = (magnifier)(image, exception);
8957
+ GVL_STRUCT_TYPE(magnify) args = { image, exception };
8958
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
8556
8959
  rm_check_exception(exception, new_image, DestroyOnError);
8557
8960
 
8558
8961
  DestroyExceptionInfo(exception);
@@ -8579,7 +8982,7 @@ VALUE
8579
8982
  Image_magnify(VALUE self)
8580
8983
  {
8581
8984
  rm_check_destroyed(self);
8582
- return magnify(False, self, MagnifyImage);
8985
+ return magnify(False, self, GVL_FUNC(MagnifyImage));
8583
8986
  }
8584
8987
 
8585
8988
 
@@ -8594,7 +8997,7 @@ VALUE
8594
8997
  Image_magnify_bang(VALUE self)
8595
8998
  {
8596
8999
  rm_check_frozen(self);
8597
- return magnify(True, self, MagnifyImage);
9000
+ return magnify(True, self, GVL_FUNC(MagnifyImage));
8598
9001
  }
8599
9002
 
8600
9003
 
@@ -8626,7 +9029,8 @@ Image_marshal_dump(VALUE self)
8626
9029
  rb_ary_store(ary, 0, rb_str_new2(image->filename));
8627
9030
 
8628
9031
  exception = AcquireExceptionInfo();
8629
- 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);
8630
9034
 
8631
9035
  // Destroy info before raising an exception
8632
9036
  DestroyImageInfo(info);
@@ -8671,7 +9075,8 @@ Image_marshal_load(VALUE self, VALUE ary)
8671
9075
  {
8672
9076
  strlcpy(info->filename, RSTRING_PTR(filename), sizeof(info->filename));
8673
9077
  }
8674
- 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);
8675
9080
 
8676
9081
  // Destroy info before raising an exception
8677
9082
  DestroyImageInfo(info);
@@ -8704,9 +9109,11 @@ get_image_mask(Image *image)
8704
9109
 
8705
9110
  // The returned clip mask is a clone, ours to keep.
8706
9111
  #if defined(IMAGEMAGICK_7)
8707
- 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);
8708
9114
  #else
8709
- mask = GetImageClipMask(image, exception);
9115
+ GVL_STRUCT_TYPE(GetImageClipMask) args = { image, exception };
9116
+ mask = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(GetImageClipMask), &args);
8710
9117
  #endif
8711
9118
  rm_check_exception(exception, mask, DestroyOnError);
8712
9119
 
@@ -8744,19 +9151,22 @@ set_image_mask(Image *image, VALUE mask)
8744
9151
  // Resize if necessary
8745
9152
  if (clip_mask->columns != image->columns || clip_mask->rows != image->rows)
8746
9153
  {
8747
- 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);
8748
9156
  DestroyImage(clip_mask);
8749
9157
  rm_check_exception(exception, resized_image, DestroyOnError);
8750
9158
  rm_ensure_result(resized_image);
8751
9159
  clip_mask = resized_image;
8752
9160
  }
8753
9161
 
8754
- 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);
8755
9164
  DestroyImage(clip_mask);
8756
9165
  }
8757
9166
  else
8758
9167
  {
8759
- SetImageMask(image, WritePixelMask, NULL, exception);
9168
+ GVL_STRUCT_TYPE(SetImageMask) args = { image, WritePixelMask, NULL, exception };
9169
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageMask), &args);
8760
9170
  }
8761
9171
  CHECK_EXCEPTION();
8762
9172
  DestroyExceptionInfo(exception);
@@ -8784,8 +9194,8 @@ set_image_mask(Image *image, VALUE mask)
8784
9194
  if (clip_mask->columns != image->columns || clip_mask->rows != image->rows)
8785
9195
  {
8786
9196
  exception = AcquireExceptionInfo();
8787
- resized_image = ResizeImage(clip_mask, image->columns, image->rows,
8788
- 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);
8789
9199
  rm_check_exception(exception, resized_image, DestroyOnError);
8790
9200
  DestroyExceptionInfo(exception);
8791
9201
  rm_ensure_result(resized_image);
@@ -8798,7 +9208,8 @@ set_image_mask(Image *image, VALUE mask)
8798
9208
 
8799
9209
  for (y = 0; y < (long) clip_mask->rows; y++)
8800
9210
  {
8801
- 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);
8802
9213
  rm_check_exception(exception, clip_mask, DestroyOnError);
8803
9214
 
8804
9215
  if (!q)
@@ -8817,12 +9228,14 @@ set_image_mask(Image *image, VALUE mask)
8817
9228
  q += 1;
8818
9229
  }
8819
9230
 
8820
- SyncAuthenticPixels(clip_mask, exception);
9231
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args_SyncAuthenticPixels = { clip_mask, exception };
9232
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args_SyncAuthenticPixels);
8821
9233
  rm_check_exception(exception, clip_mask, DestroyOnError);
8822
9234
  }
8823
9235
  DestroyExceptionInfo(exception);
8824
9236
 
8825
- SetImageStorageClass(clip_mask, DirectClass);
9237
+ GVL_STRUCT_TYPE(SetImageStorageClass) args_SetImageStorageClass = { clip_mask, DirectClass };
9238
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args_SetImageStorageClass);
8826
9239
  rm_check_image_exception(clip_mask, DestroyOnError);
8827
9240
 
8828
9241
  clip_mask->matte = MagickTrue;
@@ -8830,12 +9243,14 @@ set_image_mask(Image *image, VALUE mask)
8830
9243
  // SetImageClipMask clones the clip_mask image. We can
8831
9244
  // destroy our copy after SetImageClipMask is done with it.
8832
9245
 
8833
- SetImageClipMask(image, clip_mask);
9246
+ GVL_STRUCT_TYPE(SetImageClipMask) args_SetImageClipMask = { image, clip_mask };
9247
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageClipMask), &args_SetImageClipMask);
8834
9248
  DestroyImage(clip_mask);
8835
9249
  }
8836
9250
  else
8837
9251
  {
8838
- SetImageClipMask(image, NULL);
9252
+ GVL_STRUCT_TYPE(SetImageClipMask) args_SetImageClipMask = { image, NULL };
9253
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageClipMask), &args_SetImageClipMask);
8839
9254
  }
8840
9255
 
8841
9256
  RB_GC_GUARD(mask);
@@ -9009,13 +9424,15 @@ Image_matte_flood_fill(int argc, VALUE *argv, VALUE self)
9009
9424
  #if defined(IMAGEMAGICK_7)
9010
9425
  exception = AcquireExceptionInfo();
9011
9426
  BEGIN_CHANNEL_MASK(new_image, OpacityChannel);
9012
- 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);
9013
9429
  END_CHANNEL_MASK(new_image);
9014
9430
  DestroyDrawInfo(draw_info);
9015
9431
  rm_check_exception(exception, new_image, DestroyOnError);
9016
9432
  DestroyExceptionInfo(exception);
9017
9433
  #else
9018
- 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);
9019
9436
  DestroyDrawInfo(draw_info);
9020
9437
 
9021
9438
  rm_check_image_exception(new_image, DestroyOnError);
@@ -9053,7 +9470,8 @@ Image_median_filter(int argc, VALUE *argv, VALUE self)
9053
9470
  }
9054
9471
 
9055
9472
  exception = AcquireExceptionInfo();
9056
- 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);
9057
9475
  rm_check_exception(exception, new_image, DestroyOnError);
9058
9476
  DestroyExceptionInfo(exception);
9059
9477
 
@@ -9069,7 +9487,7 @@ Image_median_filter(int argc, VALUE *argv, VALUE self)
9069
9487
  VALUE
9070
9488
  Image_mean_error_per_pixel(VALUE self)
9071
9489
  {
9072
- 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);
9073
9491
  }
9074
9492
 
9075
9493
 
@@ -9112,7 +9530,7 @@ VALUE
9112
9530
  Image_minify(VALUE self)
9113
9531
  {
9114
9532
  rm_check_destroyed(self);
9115
- return magnify(False, self, MinifyImage);
9533
+ return magnify(False, self, GVL_FUNC(MinifyImage));
9116
9534
  }
9117
9535
 
9118
9536
 
@@ -9126,7 +9544,7 @@ VALUE
9126
9544
  Image_minify_bang(VALUE self)
9127
9545
  {
9128
9546
  rm_check_frozen(self);
9129
- return magnify(True, self, MinifyImage);
9547
+ return magnify(True, self, GVL_FUNC(MinifyImage));
9130
9548
  }
9131
9549
 
9132
9550
 
@@ -9178,11 +9596,13 @@ Image_modulate(int argc, VALUE *argv, VALUE self)
9178
9596
 
9179
9597
  #if defined(IMAGEMAGICK_7)
9180
9598
  exception = AcquireExceptionInfo();
9181
- ModulateImage(new_image, modulate, exception);
9599
+ GVL_STRUCT_TYPE(ModulateImage) args = { new_image, modulate, exception };
9600
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ModulateImage), &args);
9182
9601
  rm_check_exception(exception, new_image, DestroyOnError);
9183
9602
  DestroyExceptionInfo(exception);
9184
9603
  #else
9185
- ModulateImage(new_image, modulate);
9604
+ GVL_STRUCT_TYPE(ModulateImage) args = { new_image, modulate };
9605
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(ModulateImage), &args);
9186
9606
  rm_check_image_exception(new_image, DestroyOnError);
9187
9607
  #endif
9188
9608
 
@@ -9190,42 +9610,6 @@ Image_modulate(int argc, VALUE *argv, VALUE self)
9190
9610
  }
9191
9611
 
9192
9612
 
9193
- /**
9194
- * Establish a progress monitor.
9195
- *
9196
- * - A progress monitor is a callable object. Save the monitor proc as the client_data and establish
9197
- * `progress_monitor' as the monitor exit. When `progress_monitor' is called, retrieve the proc
9198
- * and call it.
9199
- *
9200
- * @param monitor [Proc] the progress monitor
9201
- * @return [Proc] the given value
9202
- * @example
9203
- * img.monitor = Proc.new do |method, offset, span|
9204
- * print "%s is %3.0f%% complete.\n", method, (offset.to_f/span)*100)
9205
- * true
9206
- * end
9207
- * @deprecated Magick::Image#monitor= is deprecated. This method will be removed in RMagick 5.0.
9208
- */
9209
- VALUE
9210
- Image_monitor_eq(VALUE self, VALUE monitor)
9211
- {
9212
- Image *image = rm_check_frozen(self);
9213
-
9214
- rb_warning("Magick::Image#monitor= is deprecated. This method will be removed in RMagick 5.0.");
9215
-
9216
- if (NIL_P(monitor))
9217
- {
9218
- image->progress_monitor = NULL;
9219
- }
9220
- else
9221
- {
9222
- SetImageProgressMonitor(image, rm_progress_monitor, (void *)monitor);
9223
- }
9224
-
9225
- return monitor;
9226
- }
9227
-
9228
-
9229
9613
  /**
9230
9614
  * Return true if all the pixels in the image have the same red, green, and blue intensities and the
9231
9615
  * intensity is either 0 or {Magick::QuantumRange}.
@@ -9251,10 +9635,13 @@ Image_monochrome_q(VALUE self)
9251
9635
  VALUE
9252
9636
  Image_montage(VALUE self)
9253
9637
  {
9254
- IMPLEMENT_ATTR_READER(Image, montage, str);
9638
+ IMPLEMENT_TYPED_ATTR_READER(Image, montage, str, &rm_image_data_type);
9255
9639
  }
9256
9640
 
9257
9641
 
9642
+ // aliases for common use of structure types; MotionBlurImage, SketchImage
9643
+ typedef GVL_STRUCT_TYPE(MotionBlurImage) GVL_STRUCT_TYPE(motion_blur);
9644
+
9258
9645
  /**
9259
9646
  * Called from Image_motion_blur and Image_sketch.
9260
9647
  *
@@ -9269,8 +9656,7 @@ Image_montage(VALUE self)
9269
9656
  * @see Image_sketch
9270
9657
  */
9271
9658
  static VALUE
9272
- motion_blur(int argc, VALUE *argv, VALUE self,
9273
- Image *fp(const Image *, const double, const double, const double, ExceptionInfo *))
9659
+ motion_blur(int argc, VALUE *argv, VALUE self, gvl_function_t fp)
9274
9660
  {
9275
9661
  Image *image, *new_image;
9276
9662
  double radius = 0.0;
@@ -9298,10 +9684,11 @@ motion_blur(int argc, VALUE *argv, VALUE self,
9298
9684
  rb_raise(rb_eArgError, "sigma must be != 0.0");
9299
9685
  }
9300
9686
 
9301
- Data_Get_Struct(self, Image, image);
9687
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
9302
9688
 
9303
9689
  exception = AcquireExceptionInfo();
9304
- 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);
9305
9692
  rm_check_exception(exception, new_image, DestroyOnError);
9306
9693
  DestroyExceptionInfo(exception);
9307
9694
 
@@ -9325,7 +9712,7 @@ VALUE
9325
9712
  Image_motion_blur(int argc, VALUE *argv, VALUE self)
9326
9713
  {
9327
9714
  rm_check_destroyed(self);
9328
- return motion_blur(argc, argv, self, MotionBlurImage);
9715
+ return motion_blur(argc, argv, self, GVL_FUNC(MotionBlurImage));
9329
9716
  }
9330
9717
 
9331
9718
 
@@ -9360,11 +9747,13 @@ Image_negate(int argc, VALUE *argv, VALUE self)
9360
9747
 
9361
9748
  #if defined(IMAGEMAGICK_7)
9362
9749
  exception = AcquireExceptionInfo();
9363
- NegateImage(new_image, grayscale, exception);
9750
+ GVL_STRUCT_TYPE(NegateImage) args = { new_image, grayscale, exception };
9751
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args);
9364
9752
  rm_check_exception(exception, new_image, DestroyOnError);
9365
9753
  DestroyExceptionInfo(exception);
9366
9754
  #else
9367
- NegateImage(new_image, grayscale);
9755
+ GVL_STRUCT_TYPE(NegateImage) args = { new_image, grayscale };
9756
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args);
9368
9757
  rm_check_image_exception(new_image, DestroyOnError);
9369
9758
  #endif
9370
9759
 
@@ -9417,12 +9806,14 @@ Image_negate_channel(int argc, VALUE *argv, VALUE self)
9417
9806
  #if defined(IMAGEMAGICK_7)
9418
9807
  exception = AcquireExceptionInfo();
9419
9808
  BEGIN_CHANNEL_MASK(new_image, channels);
9420
- NegateImage(new_image, grayscale, exception);
9809
+ GVL_STRUCT_TYPE(NegateImage) args = { new_image, grayscale, exception };
9810
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImage), &args);
9421
9811
  END_CHANNEL_MASK(new_image);
9422
9812
  rm_check_exception(exception, new_image, DestroyOnError);
9423
9813
  DestroyExceptionInfo(exception);
9424
9814
  #else
9425
- NegateImageChannel(new_image, channels, grayscale);
9815
+ GVL_STRUCT_TYPE(NegateImageChannel) args = { new_image, channels, grayscale };
9816
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NegateImageChannel), &args);
9426
9817
  rm_check_image_exception(new_image, DestroyOnError);
9427
9818
  #endif
9428
9819
 
@@ -9440,7 +9831,7 @@ Image_alloc(VALUE class)
9440
9831
  {
9441
9832
  VALUE image_obj;
9442
9833
 
9443
- image_obj = Data_Wrap_Struct(class, NULL, rm_image_destroy, NULL);
9834
+ image_obj = TypedData_Wrap_Struct(class, &rm_image_data_type, NULL);
9444
9835
 
9445
9836
  RB_GC_GUARD(image_obj);
9446
9837
 
@@ -9484,7 +9875,7 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9484
9875
 
9485
9876
  // Create a new Info object to use when creating this image.
9486
9877
  info_obj = rm_info_new();
9487
- Data_Get_Struct(info_obj, Info, info);
9878
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
9488
9879
 
9489
9880
  image = rm_acquire_image(info);
9490
9881
  if (!image)
@@ -9499,11 +9890,13 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9499
9890
 
9500
9891
  #if defined(IMAGEMAGICK_7)
9501
9892
  exception = AcquireExceptionInfo();
9502
- SetImageExtent(image, cols, rows, exception);
9893
+ GVL_STRUCT_TYPE(SetImageExtent) args = { image, cols, rows, exception };
9894
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageExtent), &args);
9503
9895
  CHECK_EXCEPTION();
9504
9896
  DestroyExceptionInfo(exception);
9505
9897
  #else
9506
- SetImageExtent(image, cols, rows);
9898
+ GVL_STRUCT_TYPE(SetImageExtent) args = { image, cols, rows };
9899
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageExtent), &args);
9507
9900
  #endif
9508
9901
 
9509
9902
  // If the caller did not supply a fill argument, call SetImageBackgroundColor
@@ -9513,11 +9906,13 @@ Image_initialize(int argc, VALUE *argv, VALUE self)
9513
9906
  {
9514
9907
  #if defined(IMAGEMAGICK_7)
9515
9908
  exception = AcquireExceptionInfo();
9516
- SetImageBackgroundColor(image, exception);
9909
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image, exception };
9910
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
9517
9911
  CHECK_EXCEPTION();
9518
9912
  DestroyExceptionInfo(exception);
9519
9913
  #else
9520
- SetImageBackgroundColor(image);
9914
+ GVL_STRUCT_TYPE(SetImageBackgroundColor) args = { image };
9915
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageBackgroundColor), &args);
9521
9916
  #endif
9522
9917
  }
9523
9918
  // fillobj.fill(self)
@@ -9550,9 +9945,7 @@ rm_image_new(Image *image)
9550
9945
  {
9551
9946
  rm_ensure_result(image);
9552
9947
 
9553
- rm_trace_creation(image);
9554
-
9555
- return Data_Wrap_Struct(Class_Image, NULL, rm_image_destroy, image);
9948
+ return TypedData_Wrap_Struct(Class_Image, &rm_image_data_type, image);
9556
9949
  }
9557
9950
 
9558
9951
 
@@ -9575,11 +9968,13 @@ Image_normalize(VALUE self)
9575
9968
 
9576
9969
  #if defined(IMAGEMAGICK_7)
9577
9970
  exception = AcquireExceptionInfo();
9578
- NormalizeImage(new_image, exception);
9971
+ GVL_STRUCT_TYPE(NormalizeImage) args = { new_image, exception };
9972
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImage), &args);
9579
9973
  rm_check_exception(exception, new_image, DestroyOnError);
9580
9974
  DestroyExceptionInfo(exception);
9581
9975
  #else
9582
- NormalizeImage(new_image);
9976
+ GVL_STRUCT_TYPE(NormalizeImage) args = { new_image };
9977
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImage), &args);
9583
9978
  rm_check_image_exception(new_image, DestroyOnError);
9584
9979
  #endif
9585
9980
 
@@ -9617,12 +10012,14 @@ Image_normalize_channel(int argc, VALUE *argv, VALUE self)
9617
10012
  #if defined(IMAGEMAGICK_7)
9618
10013
  exception = AcquireExceptionInfo();
9619
10014
  BEGIN_CHANNEL_MASK(new_image, channels);
9620
- NormalizeImage(new_image, exception);
10015
+ GVL_STRUCT_TYPE(NormalizeImage) args = { new_image, exception };
10016
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImage), &args);
9621
10017
  END_CHANNEL_MASK(new_image);
9622
10018
  rm_check_exception(exception, new_image, DestroyOnError);
9623
10019
  DestroyExceptionInfo(exception);
9624
10020
  #else
9625
- NormalizeImageChannel(new_image, channels);
10021
+ GVL_STRUCT_TYPE(NormalizeImageChannel) args = { new_image, channels };
10022
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(NormalizeImageChannel), &args);
9626
10023
  rm_check_image_exception(new_image, DestroyOnError);
9627
10024
  #endif
9628
10025
 
@@ -9638,7 +10035,7 @@ Image_normalize_channel(int argc, VALUE *argv, VALUE self)
9638
10035
  VALUE
9639
10036
  Image_normalized_mean_error(VALUE self)
9640
10037
  {
9641
- 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);
9642
10039
  }
9643
10040
 
9644
10041
  /**
@@ -9649,7 +10046,7 @@ Image_normalized_mean_error(VALUE self)
9649
10046
  VALUE
9650
10047
  Image_normalized_maximum_error(VALUE self)
9651
10048
  {
9652
- 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);
9653
10050
  }
9654
10051
 
9655
10052
 
@@ -9663,12 +10060,13 @@ Image_number_colors(VALUE self)
9663
10060
  {
9664
10061
  Image *image;
9665
10062
  ExceptionInfo *exception;
9666
- unsigned long n = 0;
10063
+ size_t n = 0;
9667
10064
 
9668
10065
  image = rm_check_destroyed(self);
9669
10066
  exception = AcquireExceptionInfo();
9670
10067
 
9671
- 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);
9672
10070
  CHECK_EXCEPTION();
9673
10071
 
9674
10072
  DestroyExceptionInfo(exception);
@@ -9685,7 +10083,7 @@ Image_number_colors(VALUE self)
9685
10083
  VALUE
9686
10084
  Image_offset(VALUE self)
9687
10085
  {
9688
- IMPLEMENT_ATTR_READER(Image, offset, long);
10086
+ IMPLEMENT_TYPED_ATTR_READER(Image, offset, long, &rm_image_data_type);
9689
10087
  }
9690
10088
 
9691
10089
  /**
@@ -9697,7 +10095,7 @@ Image_offset(VALUE self)
9697
10095
  VALUE
9698
10096
  Image_offset_eq(VALUE self, VALUE val)
9699
10097
  {
9700
- IMPLEMENT_ATTR_WRITER(Image, offset, long);
10098
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, offset, long, &rm_image_data_type);
9701
10099
  }
9702
10100
 
9703
10101
 
@@ -9733,10 +10131,11 @@ Image_oil_paint(int argc, VALUE *argv, VALUE self)
9733
10131
  exception = AcquireExceptionInfo();
9734
10132
 
9735
10133
  #if defined(IMAGEMAGICK_7)
9736
- new_image = OilPaintImage(image, radius, sigma, exception);
10134
+ GVL_STRUCT_TYPE(OilPaintImage) args = { image, radius, sigma, exception };
9737
10135
  #else
9738
- new_image = OilPaintImage(image, radius, exception);
10136
+ GVL_STRUCT_TYPE(OilPaintImage) args = { image, radius, exception };
9739
10137
  #endif
10138
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(OilPaintImage), &args);
9740
10139
  rm_check_exception(exception, new_image, DestroyOnError);
9741
10140
  DestroyExceptionInfo(exception);
9742
10141
 
@@ -9777,11 +10176,13 @@ Image_opaque(VALUE self, VALUE target, VALUE fill)
9777
10176
 
9778
10177
  #if defined(IMAGEMAGICK_7)
9779
10178
  exception = AcquireExceptionInfo();
9780
- 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);
9781
10181
  rm_check_exception(exception, new_image, DestroyOnError);
9782
10182
  DestroyExceptionInfo(exception);
9783
10183
  #else
9784
- 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);
9785
10186
  rm_check_image_exception(new_image, DestroyOnError);
9786
10187
  #endif
9787
10188
 
@@ -9867,13 +10268,15 @@ Image_opaque_channel(int argc, VALUE *argv, VALUE self)
9867
10268
  #if defined(IMAGEMAGICK_7)
9868
10269
  exception = AcquireExceptionInfo();
9869
10270
  BEGIN_CHANNEL_MASK(new_image, channels);
9870
- 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);
9871
10273
  END_CHANNEL_MASK(new_image);
9872
10274
  new_image->fuzz = keep;
9873
10275
  rm_check_exception(exception, new_image, DestroyOnError);
9874
10276
  DestroyExceptionInfo(exception);
9875
10277
  #else
9876
- 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);
9877
10280
 
9878
10281
  new_image->fuzz = keep;
9879
10282
  rm_check_image_exception(new_image, DestroyOnError);
@@ -9958,7 +10361,13 @@ Image_ordered_dither(int argc, VALUE *argv, VALUE self)
9958
10361
 
9959
10362
  exception = AcquireExceptionInfo();
9960
10363
 
9961
- 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
9962
10371
  rm_check_exception(exception, new_image, DestroyOnError);
9963
10372
 
9964
10373
  DestroyExceptionInfo(exception);
@@ -10093,12 +10502,14 @@ Image_paint_transparent(int argc, VALUE *argv, VALUE self)
10093
10502
 
10094
10503
  #if defined(IMAGEMAGICK_7)
10095
10504
  exception = AcquireExceptionInfo();
10096
- 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);
10097
10507
  new_image->fuzz = keep;
10098
10508
  rm_check_exception(exception, new_image, DestroyOnError);
10099
10509
  DestroyExceptionInfo(exception);
10100
10510
  #else
10101
- 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);
10102
10513
  new_image->fuzz = keep;
10103
10514
 
10104
10515
  // Is it possible for TransparentPaintImage to silently fail?
@@ -10141,7 +10552,7 @@ Image_palette_q(VALUE self)
10141
10552
  VALUE
10142
10553
  Image_ping(VALUE class, VALUE file_arg)
10143
10554
  {
10144
- return rd_image(class, file_arg, PingImage);
10555
+ return rd_image(class, file_arg, GVL_FUNC(PingImage));
10145
10556
  }
10146
10557
 
10147
10558
 
@@ -10207,7 +10618,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10207
10618
  if (!set)
10208
10619
  {
10209
10620
  exception = AcquireExceptionInfo();
10210
- 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);
10211
10623
  CHECK_EXCEPTION();
10212
10624
 
10213
10625
  DestroyExceptionInfo(exception);
@@ -10259,7 +10671,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10259
10671
  if (image->storage_class == PseudoClass)
10260
10672
  {
10261
10673
  #if defined(IMAGEMAGICK_7)
10262
- 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);
10263
10676
  CHECK_EXCEPTION();
10264
10677
  if (!okay)
10265
10678
  {
@@ -10267,7 +10680,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10267
10680
  rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't set pixel color.");
10268
10681
  }
10269
10682
  #else
10270
- okay = SetImageStorageClass(image, DirectClass);
10683
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
10684
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
10271
10685
  rm_check_image_exception(image, RetainOnError);
10272
10686
  if (!okay)
10273
10687
  {
@@ -10280,7 +10694,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10280
10694
  exception = AcquireExceptionInfo();
10281
10695
  #endif
10282
10696
 
10283
- 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);
10284
10699
  CHECK_EXCEPTION();
10285
10700
 
10286
10701
  if (pixel)
@@ -10315,7 +10730,8 @@ Image_pixel_color(int argc, VALUE *argv, VALUE self)
10315
10730
  }
10316
10731
  #endif
10317
10732
 
10318
- SyncAuthenticPixels(image, exception);
10733
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
10734
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
10319
10735
  CHECK_EXCEPTION();
10320
10736
  }
10321
10737
 
@@ -10404,7 +10820,7 @@ Image_polaroid(int argc, VALUE *argv, VALUE self)
10404
10820
  }
10405
10821
 
10406
10822
  options = rm_polaroid_new();
10407
- Data_Get_Struct(options, Draw, draw);
10823
+ TypedData_Get_Struct(options, Draw, &rm_draw_data_type, draw);
10408
10824
 
10409
10825
  clone = rm_clone_image(image);
10410
10826
  clone->background_color = draw->shadow_color;
@@ -10413,9 +10829,11 @@ Image_polaroid(int argc, VALUE *argv, VALUE self)
10413
10829
  exception = AcquireExceptionInfo();
10414
10830
  #if defined(IMAGEMAGICK_7)
10415
10831
  caption = GetImageProperty(clone, "Caption", exception);
10416
- 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);
10417
10834
  #else
10418
- 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);
10419
10837
  #endif
10420
10838
  rm_check_exception(exception, clone, DestroyOnError);
10421
10839
 
@@ -10467,11 +10885,13 @@ Image_posterize(int argc, VALUE *argv, VALUE self)
10467
10885
  #if defined(IMAGEMAGICK_7)
10468
10886
  exception = AcquireExceptionInfo();
10469
10887
  dither_method = dither ? RiemersmaDitherMethod : NoDitherMethod;
10470
- 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);
10471
10890
  rm_check_exception(exception, new_image, DestroyOnError);
10472
10891
  DestroyExceptionInfo(exception);
10473
10892
  #else
10474
- PosterizeImage(new_image, levels, dither);
10893
+ GVL_STRUCT_TYPE(PosterizeImage) args = { new_image, levels, dither };
10894
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(PosterizeImage), &args);
10475
10895
  rm_check_image_exception(new_image, DestroyOnError);
10476
10896
  #endif
10477
10897
 
@@ -10497,7 +10917,8 @@ Image_preview(VALUE self, VALUE preview)
10497
10917
  VALUE_TO_ENUM(preview, preview_type, PreviewType);
10498
10918
 
10499
10919
  exception = AcquireExceptionInfo();
10500
- 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);
10501
10922
  rm_check_exception(exception, new_image, DestroyOnError);
10502
10923
 
10503
10924
  DestroyExceptionInfo(exception);
@@ -10538,7 +10959,7 @@ Image_profile_bang(VALUE self, VALUE name, VALUE profile)
10538
10959
  VALUE
10539
10960
  Image_quality(VALUE self)
10540
10961
  {
10541
- IMPLEMENT_ATTR_READER(Image, quality, ulong);
10962
+ IMPLEMENT_TYPED_ATTR_READER(Image, quality, ulong, &rm_image_data_type);
10542
10963
  }
10543
10964
 
10544
10965
 
@@ -10724,10 +11145,12 @@ Image_quantum_operator(int argc, VALUE *argv, VALUE self)
10724
11145
  exception = AcquireExceptionInfo();
10725
11146
  #if defined(IMAGEMAGICK_7)
10726
11147
  BEGIN_CHANNEL_MASK(image, channel);
10727
- EvaluateImage(image, qop, rvalue, exception);
11148
+ GVL_STRUCT_TYPE(EvaluateImage) args = { image, qop, rvalue, exception };
11149
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(EvaluateImage), &args);
10728
11150
  END_CHANNEL_MASK(image);
10729
11151
  #else
10730
- 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);
10731
11154
  #endif
10732
11155
  CHECK_EXCEPTION();
10733
11156
 
@@ -10804,11 +11227,13 @@ Image_quantize(int argc, VALUE *argv, VALUE self)
10804
11227
 
10805
11228
  #if defined(IMAGEMAGICK_7)
10806
11229
  exception = AcquireExceptionInfo();
10807
- 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);
10808
11232
  rm_check_exception(exception, new_image, DestroyOnError);
10809
11233
  DestroyExceptionInfo(exception);
10810
11234
  #else
10811
- QuantizeImage(&quantize_info, new_image);
11235
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &quantize_info, new_image };
11236
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
10812
11237
  rm_check_image_exception(new_image, DestroyOnError);
10813
11238
  #endif
10814
11239
 
@@ -10833,9 +11258,11 @@ Image_radial_blur(VALUE self, VALUE angle_obj)
10833
11258
  exception = AcquireExceptionInfo();
10834
11259
 
10835
11260
  #if defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10836
- 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);
10837
11263
  #else
10838
- 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);
10839
11266
  #endif
10840
11267
  rm_check_exception(exception, new_image, DestroyOnError);
10841
11268
  DestroyExceptionInfo(exception);
@@ -10883,13 +11310,16 @@ Image_radial_blur_channel(int argc, VALUE *argv, VALUE self)
10883
11310
 
10884
11311
  #if defined(IMAGEMAGICK_7)
10885
11312
  BEGIN_CHANNEL_MASK(image, channels);
10886
- 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);
10887
11315
  CHANGE_RESULT_CHANNEL_MASK(new_image);
10888
11316
  END_CHANNEL_MASK(image);
10889
11317
  #elif defined(IMAGEMAGICK_GREATER_THAN_EQUAL_6_8_9)
10890
- 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);
10891
11320
  #else
10892
- 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);
10893
11323
  #endif
10894
11324
  rm_check_exception(exception, new_image, DestroyOnError);
10895
11325
  DestroyExceptionInfo(exception);
@@ -10950,11 +11380,13 @@ Image_random_threshold_channel(int argc, VALUE *argv, VALUE self)
10950
11380
  GeometryInfo geometry_info;
10951
11381
 
10952
11382
  ParseGeometry(thresholds, &geometry_info);
10953
- 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);
10954
11385
  }
10955
11386
  END_CHANNEL_MASK(new_image);
10956
11387
  #else
10957
- 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);
10958
11390
  #endif
10959
11391
  rm_check_exception(exception, new_image, DestroyOnError);
10960
11392
 
@@ -11011,11 +11443,13 @@ Image_raise(int argc, VALUE *argv, VALUE self)
11011
11443
 
11012
11444
  #if defined(IMAGEMAGICK_7)
11013
11445
  exception = AcquireExceptionInfo();
11014
- 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);
11015
11448
  rm_check_exception(exception, new_image, DestroyOnError);
11016
11449
  DestroyExceptionInfo(exception);
11017
11450
  #else
11018
- RaiseImage(new_image, &rect, raised);
11451
+ GVL_STRUCT_TYPE(RaiseImage) args = { new_image, &rect, raised };
11452
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(RaiseImage), &args);
11019
11453
  rm_check_image_exception(new_image, DestroyOnError);
11020
11454
  #endif
11021
11455
 
@@ -11032,7 +11466,7 @@ Image_raise(int argc, VALUE *argv, VALUE self)
11032
11466
  VALUE
11033
11467
  Image_read(VALUE class, VALUE file_arg)
11034
11468
  {
11035
- return rd_image(class, file_arg, ReadImage);
11469
+ return rd_image(class, file_arg, GVL_FUNC(ReadImage));
11036
11470
  }
11037
11471
 
11038
11472
 
@@ -11052,6 +11486,9 @@ file_arg_rescue(VALUE arg, VALUE raised_exc ATTRIBUTE_UNUSED)
11052
11486
  }
11053
11487
 
11054
11488
 
11489
+ // aliases for common use of structure types; PingImage, ReadImage
11490
+ typedef GVL_STRUCT_TYPE(PingImage) GVL_STRUCT_TYPE(rd_image);
11491
+
11055
11492
  /**
11056
11493
  * Transform arguments, call either ReadImage or PingImage.
11057
11494
  *
@@ -11077,7 +11514,7 @@ void sig_handler(int sig ATTRIBUTE_UNUSED)
11077
11514
  #endif
11078
11515
 
11079
11516
  static VALUE
11080
- rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, reader_t reader)
11517
+ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, gvl_function_t fp)
11081
11518
  {
11082
11519
  char *filename;
11083
11520
  long filename_l;
@@ -11088,7 +11525,7 @@ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, reader_t reader)
11088
11525
 
11089
11526
  // Create a new Info structure for this read/ping
11090
11527
  info_obj = rm_info_new();
11091
- Data_Get_Struct(info_obj, Info, info);
11528
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
11092
11529
 
11093
11530
  if (TYPE(file) == T_FILE)
11094
11531
  {
@@ -11128,7 +11565,8 @@ rd_image(VALUE class ATTRIBUTE_UNUSED, VALUE file, reader_t reader)
11128
11565
  }
11129
11566
  #endif
11130
11567
 
11131
- images = (reader)(info, exception);
11568
+ GVL_STRUCT_TYPE(rd_image) args = { info, exception };
11569
+ images = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
11132
11570
 
11133
11571
  #if defined(__APPLE__) || defined(__FreeBSD__)
11134
11572
  if (sigaction(SIGCHLD, &oldact, NULL) < 0)
@@ -11213,7 +11651,8 @@ Image_recolor(VALUE self, VALUE color_matrix)
11213
11651
  kernel_info->height = order;
11214
11652
  kernel_info->values = (double *) matrix;
11215
11653
 
11216
- 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);
11217
11656
  kernel_info->values = (double *) NULL;
11218
11657
  DestroyKernelInfo(kernel_info);
11219
11658
  xfree((void *) matrix);
@@ -11260,7 +11699,8 @@ Image_read_inline(VALUE self ATTRIBUTE_UNUSED, VALUE content)
11260
11699
  image_data += x + 1;
11261
11700
  }
11262
11701
 
11263
- 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);
11264
11704
  if (blob_l == 0)
11265
11705
  {
11266
11706
  rb_raise(rb_eArgError, "can't decode image");
@@ -11271,9 +11711,10 @@ Image_read_inline(VALUE self ATTRIBUTE_UNUSED, VALUE content)
11271
11711
  // Create a new Info structure for this read. About the
11272
11712
  // only useful attribute that can be set is `format'.
11273
11713
  info_obj = rm_info_new();
11274
- Data_Get_Struct(info_obj, Info, info);
11714
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
11275
11715
 
11276
- 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);
11277
11718
  magick_free((void *)blob);
11278
11719
 
11279
11720
  rm_check_exception(exception, images, DestroyOnError);
@@ -11335,7 +11776,8 @@ Image_reduce_noise(VALUE self, VALUE radius)
11335
11776
  image = rm_check_destroyed(self);
11336
11777
 
11337
11778
  exception = AcquireExceptionInfo();
11338
- 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);
11339
11781
  rm_check_exception(exception, new_image, DestroyOnError);
11340
11782
 
11341
11783
  DestroyExceptionInfo(exception);
@@ -11387,11 +11829,13 @@ Image_remap(int argc, VALUE *argv, VALUE self)
11387
11829
 
11388
11830
  #if defined(IMAGEMAGICK_7)
11389
11831
  exception = AcquireExceptionInfo();
11390
- 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);
11391
11834
  CHECK_EXCEPTION();
11392
11835
  DestroyExceptionInfo(exception);
11393
11836
  #else
11394
- 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);
11395
11839
  rm_check_image_exception(image, RetainOnError);
11396
11840
  #endif
11397
11841
 
@@ -11446,11 +11890,13 @@ blurred_image(Image* image, double blur)
11446
11890
  exception = AcquireExceptionInfo();
11447
11891
  if (blur > 1.0)
11448
11892
  {
11449
- 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);
11450
11895
  }
11451
11896
  else
11452
11897
  {
11453
- 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);
11454
11900
  }
11455
11901
  rm_check_exception(exception, new_image, DestroyOnError);
11456
11902
  DestroyExceptionInfo(exception);
@@ -11483,7 +11929,7 @@ resample(int bang, int argc, VALUE *argv, VALUE self)
11483
11929
  double width, height;
11484
11930
  ExceptionInfo *exception;
11485
11931
 
11486
- Data_Get_Struct(self, Image, image);
11932
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
11487
11933
 
11488
11934
  // Set up defaults
11489
11935
  filter = image->filter;
@@ -11543,10 +11989,12 @@ resample(int bang, int argc, VALUE *argv, VALUE self)
11543
11989
  exception = AcquireExceptionInfo();
11544
11990
  #if defined(IMAGEMAGICK_7)
11545
11991
  Image *preprocess = blurred_image(image, blur);
11546
- 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);
11547
11994
  DestroyImage(preprocess);
11548
11995
  #else
11549
- 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);
11550
11998
  #endif
11551
11999
  rm_check_exception(exception, new_image, DestroyOnError);
11552
12000
 
@@ -11633,7 +12081,7 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
11633
12081
  double blur, drows, dcols;
11634
12082
  ExceptionInfo *exception;
11635
12083
 
11636
- Data_Get_Struct(self, Image, image);
12084
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
11637
12085
 
11638
12086
  // Set up defaults
11639
12087
  filter = image->filter;
@@ -11682,13 +12130,15 @@ resize(int bang, int argc, VALUE *argv, VALUE self)
11682
12130
  exception = AcquireExceptionInfo();
11683
12131
  #if defined(IMAGEMAGICK_7)
11684
12132
  Image *preprocess = (argc == 4) ? blurred_image(image, blur) : image;
11685
- 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);
11686
12135
  if (argc == 4)
11687
12136
  {
11688
12137
  DestroyImage(preprocess);
11689
12138
  }
11690
12139
  #else
11691
- 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);
11692
12142
  #endif
11693
12143
  rm_check_exception(exception, new_image, DestroyOnError);
11694
12144
 
@@ -11774,7 +12224,8 @@ Image_roll(VALUE self, VALUE x_offset, VALUE y_offset)
11774
12224
  image = rm_check_destroyed(self);
11775
12225
 
11776
12226
  exception = AcquireExceptionInfo();
11777
- 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);
11778
12229
  rm_check_exception(exception, new_image, DestroyOnError);
11779
12230
  DestroyExceptionInfo(exception);
11780
12231
 
@@ -11804,7 +12255,7 @@ rotate(int bang, int argc, VALUE *argv, VALUE self)
11804
12255
  long arrow_l;
11805
12256
  ExceptionInfo *exception;
11806
12257
 
11807
- Data_Get_Struct(self, Image, image);
12258
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
11808
12259
 
11809
12260
  switch (argc)
11810
12261
  {
@@ -11832,7 +12283,8 @@ rotate(int bang, int argc, VALUE *argv, VALUE self)
11832
12283
 
11833
12284
  exception = AcquireExceptionInfo();
11834
12285
 
11835
- 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);
11836
12288
  rm_check_exception(exception, new_image, DestroyOnError);
11837
12289
  DestroyExceptionInfo(exception);
11838
12290
 
@@ -11905,7 +12357,7 @@ Image_rotate_bang(int argc, VALUE *argv, VALUE self)
11905
12357
  VALUE
11906
12358
  Image_rows(VALUE self)
11907
12359
  {
11908
- IMPLEMENT_ATTR_READER(Image, rows, int);
12360
+ IMPLEMENT_TYPED_ATTR_READER(Image, rows, int, &rm_image_data_type);
11909
12361
  }
11910
12362
 
11911
12363
 
@@ -11929,7 +12381,7 @@ VALUE
11929
12381
  Image_sample(int argc, VALUE *argv, VALUE self)
11930
12382
  {
11931
12383
  rm_check_destroyed(self);
11932
- return scale(False, argc, argv, self, SampleImage);
12384
+ return scale(False, argc, argv, self, GVL_FUNC(SampleImage));
11933
12385
  }
11934
12386
 
11935
12387
 
@@ -11953,7 +12405,7 @@ VALUE
11953
12405
  Image_sample_bang(int argc, VALUE *argv, VALUE self)
11954
12406
  {
11955
12407
  rm_check_frozen(self);
11956
- return scale(True, argc, argv, self, SampleImage);
12408
+ return scale(True, argc, argv, self, GVL_FUNC(SampleImage));
11957
12409
  }
11958
12410
 
11959
12411
 
@@ -11977,7 +12429,7 @@ VALUE
11977
12429
  Image_scale(int argc, VALUE *argv, VALUE self)
11978
12430
  {
11979
12431
  rm_check_destroyed(self);
11980
- return scale(False, argc, argv, self, ScaleImage);
12432
+ return scale(False, argc, argv, self, GVL_FUNC(ScaleImage));
11981
12433
  }
11982
12434
 
11983
12435
 
@@ -12001,10 +12453,13 @@ VALUE
12001
12453
  Image_scale_bang(int argc, VALUE *argv, VALUE self)
12002
12454
  {
12003
12455
  rm_check_frozen(self);
12004
- return scale(True, argc, argv, self, ScaleImage);
12456
+ return scale(True, argc, argv, self, GVL_FUNC(ScaleImage));
12005
12457
  }
12006
12458
 
12007
12459
 
12460
+ // aliases for common use of structure types; SampleImage, ScaleImage,
12461
+ typedef GVL_STRUCT_TYPE(SampleImage) GVL_STRUCT_TYPE(scale);
12462
+
12008
12463
  /**
12009
12464
  * Call ScaleImage or SampleImage
12010
12465
  *
@@ -12026,14 +12481,14 @@ Image_scale_bang(int argc, VALUE *argv, VALUE self)
12026
12481
  * @see Image_scale_bang
12027
12482
  */
12028
12483
  static VALUE
12029
- 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)
12030
12485
  {
12031
12486
  Image *image, *new_image;
12032
12487
  unsigned long columns, rows;
12033
12488
  double scale_arg, drows, dcols;
12034
12489
  ExceptionInfo *exception;
12035
12490
 
12036
- Data_Get_Struct(self, Image, image);
12491
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
12037
12492
 
12038
12493
  switch (argc)
12039
12494
  {
@@ -12066,7 +12521,8 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
12066
12521
  }
12067
12522
 
12068
12523
  exception = AcquireExceptionInfo();
12069
- 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);
12070
12526
  rm_check_exception(exception, new_image, DestroyOnError);
12071
12527
  DestroyExceptionInfo(exception);
12072
12528
 
@@ -12091,7 +12547,7 @@ scale(int bang, int argc, VALUE *argv, VALUE self, scaler_t scaler)
12091
12547
  VALUE
12092
12548
  Image_scene(VALUE self)
12093
12549
  {
12094
- IMPLEMENT_ATTR_READER(Image, scene, ulong);
12550
+ IMPLEMENT_TYPED_ATTR_READER(Image, scene, ulong, &rm_image_data_type);
12095
12551
  }
12096
12552
 
12097
12553
 
@@ -12142,11 +12598,13 @@ Image_selective_blur_channel(int argc, VALUE *argv, VALUE self)
12142
12598
  exception = AcquireExceptionInfo();
12143
12599
  #if defined(IMAGEMAGICK_7)
12144
12600
  BEGIN_CHANNEL_MASK(image, channels);
12145
- 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);
12146
12603
  CHANGE_RESULT_CHANNEL_MASK(new_image);
12147
12604
  END_CHANNEL_MASK(image);
12148
12605
  #else
12149
- 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);
12150
12608
  #endif
12151
12609
  rm_check_exception(exception, new_image, DestroyOnError);
12152
12610
  DestroyExceptionInfo(exception);
@@ -12180,12 +12638,14 @@ Image_set_channel_depth(VALUE self, VALUE channel_arg, VALUE depth)
12180
12638
  #if defined(IMAGEMAGICK_7)
12181
12639
  exception = AcquireExceptionInfo();
12182
12640
  BEGIN_CHANNEL_MASK(image, channel);
12183
- SetImageDepth(image, channel_depth, exception);
12641
+ GVL_STRUCT_TYPE(SetImageDepth) args = { image, channel_depth, exception };
12642
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageDepth), &args);
12184
12643
  END_CHANNEL_MASK(image);
12185
12644
  CHECK_EXCEPTION();
12186
12645
  DestroyExceptionInfo(exception);
12187
12646
  #else
12188
- SetImageChannelDepth(image, channel, channel_depth);
12647
+ GVL_STRUCT_TYPE(SetImageChannelDepth) args = { image, channel, channel_depth };
12648
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageChannelDepth), &args);
12189
12649
  rm_check_image_exception(image, RetainOnError);
12190
12650
  #endif
12191
12651
 
@@ -12223,11 +12683,13 @@ Image_separate(int argc, VALUE *argv, VALUE self)
12223
12683
  exception = AcquireExceptionInfo();
12224
12684
  #if defined(IMAGEMAGICK_7)
12225
12685
  BEGIN_CHANNEL_MASK(image, channels);
12226
- 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);
12227
12688
  CHANGE_RESULT_CHANNEL_MASK(new_images);
12228
12689
  END_CHANNEL_MASK(image);
12229
12690
  #else
12230
- 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);
12231
12693
  #endif
12232
12694
  rm_check_exception(exception, new_images, DestroyOnError);
12233
12695
  DestroyExceptionInfo(exception);
@@ -12266,7 +12728,8 @@ Image_sepiatone(int argc, VALUE *argv, VALUE self)
12266
12728
  }
12267
12729
 
12268
12730
  exception = AcquireExceptionInfo();
12269
- 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);
12270
12733
  rm_check_exception(exception, new_image, DestroyOnError);
12271
12734
  DestroyExceptionInfo(exception);
12272
12735
 
@@ -12324,11 +12787,13 @@ Image_segment(int argc, VALUE *argv, VALUE self)
12324
12787
 
12325
12788
  #if defined(IMAGEMAGICK_7)
12326
12789
  exception = AcquireExceptionInfo();
12327
- 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);
12328
12792
  rm_check_exception(exception, new_image, DestroyOnError);
12329
12793
  DestroyExceptionInfo(exception);
12330
12794
  #else
12331
- 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);
12332
12797
  rm_check_image_exception(new_image, DestroyOnError);
12333
12798
  #endif
12334
12799
 
@@ -12464,7 +12929,8 @@ Image_shade(int argc, VALUE *argv, VALUE self)
12464
12929
  }
12465
12930
 
12466
12931
  exception = AcquireExceptionInfo();
12467
- 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);
12468
12934
  rm_check_exception(exception, new_image, DestroyOnError);
12469
12935
  DestroyExceptionInfo(exception);
12470
12936
 
@@ -12522,7 +12988,8 @@ Image_shadow(int argc, VALUE *argv, VALUE self)
12522
12988
  }
12523
12989
 
12524
12990
  exception = AcquireExceptionInfo();
12525
- 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);
12526
12993
  rm_check_exception(exception, new_image, DestroyOnError);
12527
12994
  DestroyExceptionInfo(exception);
12528
12995
 
@@ -12541,7 +13008,7 @@ Image_shadow(int argc, VALUE *argv, VALUE self)
12541
13008
  VALUE
12542
13009
  Image_sharpen(int argc, VALUE *argv, VALUE self)
12543
13010
  {
12544
- return effect_image(self, argc, argv, SharpenImage);
13011
+ return effect_image(self, argc, argv, GVL_FUNC(SharpenImage));
12545
13012
  }
12546
13013
 
12547
13014
 
@@ -12589,11 +13056,13 @@ Image_sharpen_channel(int argc, VALUE *argv, VALUE self)
12589
13056
  exception = AcquireExceptionInfo();
12590
13057
  #if defined(IMAGEMAGICK_7)
12591
13058
  BEGIN_CHANNEL_MASK(image, channels);
12592
- 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);
12593
13061
  CHANGE_RESULT_CHANNEL_MASK(new_image);
12594
13062
  END_CHANNEL_MASK(image);
12595
13063
  #else
12596
- 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);
12597
13066
  #endif
12598
13067
 
12599
13068
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -12616,7 +13085,7 @@ VALUE
12616
13085
  Image_shave(VALUE self, VALUE width, VALUE height)
12617
13086
  {
12618
13087
  rm_check_destroyed(self);
12619
- 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));
12620
13089
  }
12621
13090
 
12622
13091
 
@@ -12634,7 +13103,7 @@ VALUE
12634
13103
  Image_shave_bang(VALUE self, VALUE width, VALUE height)
12635
13104
  {
12636
13105
  rm_check_frozen(self);
12637
- 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));
12638
13107
  }
12639
13108
 
12640
13109
 
@@ -12661,7 +13130,8 @@ Image_shear(VALUE self, VALUE x_shear, VALUE y_shear)
12661
13130
  image = rm_check_destroyed(self);
12662
13131
 
12663
13132
  exception = AcquireExceptionInfo();
12664
- 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);
12665
13135
  rm_check_exception(exception, new_image, DestroyOnError);
12666
13136
  DestroyExceptionInfo(exception);
12667
13137
 
@@ -12732,12 +13202,14 @@ Image_sigmoidal_contrast_channel(int argc, VALUE *argv, VALUE self)
12732
13202
  #if defined(IMAGEMAGICK_7)
12733
13203
  exception = AcquireExceptionInfo();
12734
13204
  BEGIN_CHANNEL_MASK(new_image, channels);
12735
- 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);
12736
13207
  END_CHANNEL_MASK(new_image);
12737
13208
  rm_check_exception(exception, new_image, DestroyOnError);
12738
13209
  DestroyExceptionInfo(exception);
12739
13210
  #else
12740
- 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);
12741
13213
  rm_check_image_exception(new_image, DestroyOnError);
12742
13214
  #endif
12743
13215
 
@@ -12764,11 +13236,13 @@ Image_signature(VALUE self)
12764
13236
 
12765
13237
  #if defined(IMAGEMAGICK_7)
12766
13238
  exception = AcquireExceptionInfo();
12767
- SignatureImage(image, exception);
13239
+ GVL_STRUCT_TYPE(SignatureImage) args = { image, exception };
13240
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args);
12768
13241
  CHECK_EXCEPTION();
12769
13242
  DestroyExceptionInfo(exception);
12770
13243
  #else
12771
- SignatureImage(image);
13244
+ GVL_STRUCT_TYPE(SignatureImage) args = { image };
13245
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args);
12772
13246
  rm_check_image_exception(image, RetainOnError);
12773
13247
  #endif
12774
13248
  signature = rm_get_property(image, "signature");
@@ -12794,7 +13268,7 @@ VALUE
12794
13268
  Image_sketch(int argc, VALUE *argv, VALUE self)
12795
13269
  {
12796
13270
  rm_check_destroyed(self);
12797
- return motion_blur(argc, argv, self, SketchImage);
13271
+ return motion_blur(argc, argv, self, GVL_FUNC(SketchImage));
12798
13272
  }
12799
13273
 
12800
13274
 
@@ -12837,11 +13311,13 @@ Image_solarize(int argc, VALUE *argv, VALUE self)
12837
13311
 
12838
13312
  #if defined(IMAGEMAGICK_7)
12839
13313
  exception = AcquireExceptionInfo();
12840
- SolarizeImage(new_image, threshold, exception);
13314
+ GVL_STRUCT_TYPE(SolarizeImage) args = { new_image, threshold, exception };
13315
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SolarizeImage), &args);
12841
13316
  rm_check_exception(exception, new_image, DestroyOnError);
12842
13317
  DestroyExceptionInfo(exception);
12843
13318
  #else
12844
- SolarizeImage(new_image, threshold);
13319
+ GVL_STRUCT_TYPE(SolarizeImage) args = { new_image, threshold };
13320
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SolarizeImage), &args);
12845
13321
  rm_check_image_exception(new_image, DestroyOnError);
12846
13322
  #endif
12847
13323
 
@@ -12877,14 +13353,18 @@ Image_spaceship(VALUE self, VALUE other)
12877
13353
 
12878
13354
  #if defined(IMAGEMAGICK_7)
12879
13355
  exception = AcquireExceptionInfo();
12880
- SignatureImage(imageA, exception);
13356
+ GVL_STRUCT_TYPE(SignatureImage) args1 = { imageA, exception };
13357
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args1);
12881
13358
  CHECK_EXCEPTION();
12882
- SignatureImage(imageB, exception);
13359
+ GVL_STRUCT_TYPE(SignatureImage) args2 = { imageB, exception };
13360
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SignatureImage), &args2);
12883
13361
  CHECK_EXCEPTION();
12884
13362
  DestroyExceptionInfo(exception);
12885
13363
  #else
12886
- SignatureImage(imageA);
12887
- 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);
12888
13368
  #endif
12889
13369
  sigA = rm_get_property(imageA, "signature");
12890
13370
  sigB = rm_get_property(imageB, "signature");
@@ -13061,11 +13541,13 @@ Image_sparse_color(int argc, VALUE *argv, VALUE self)
13061
13541
  exception = AcquireExceptionInfo();
13062
13542
  #if defined(IMAGEMAGICK_7)
13063
13543
  BEGIN_CHANNEL_MASK(image, channels);
13064
- 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);
13065
13546
  CHANGE_RESULT_CHANNEL_MASK(new_image);
13066
13547
  END_CHANNEL_MASK(image);
13067
13548
  #else
13068
- 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);
13069
13551
  #endif
13070
13552
  xfree((void *) args);
13071
13553
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -13124,7 +13606,8 @@ Image_splice(int argc, VALUE *argv, VALUE self)
13124
13606
  // Swap in color for the duration of this call.
13125
13607
  old_color = image->background_color;
13126
13608
  image->background_color = color;
13127
- 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);
13128
13611
  image->background_color = old_color;
13129
13612
 
13130
13613
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -13162,10 +13645,11 @@ Image_spread(int argc, VALUE *argv, VALUE self)
13162
13645
 
13163
13646
  exception = AcquireExceptionInfo();
13164
13647
  #if defined(IMAGEMAGICK_7)
13165
- new_image = SpreadImage(image, image->interpolate, radius, exception);
13648
+ GVL_STRUCT_TYPE(SpreadImage) args = { image, image->interpolate, radius, exception };
13166
13649
  #else
13167
- new_image = SpreadImage(image, radius, exception);
13650
+ GVL_STRUCT_TYPE(SpreadImage) args = { image, radius, exception };
13168
13651
  #endif
13652
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SpreadImage), &args);
13169
13653
  rm_check_exception(exception, new_image, DestroyOnError);
13170
13654
  DestroyExceptionInfo(exception);
13171
13655
 
@@ -13181,7 +13665,7 @@ Image_spread(int argc, VALUE *argv, VALUE self)
13181
13665
  VALUE
13182
13666
  Image_start_loop(VALUE self)
13183
13667
  {
13184
- IMPLEMENT_ATTR_READER(Image, start_loop, boolean);
13668
+ IMPLEMENT_TYPED_ATTR_READER(Image, start_loop, boolean, &rm_image_data_type);
13185
13669
  }
13186
13670
 
13187
13671
  /**
@@ -13193,7 +13677,7 @@ Image_start_loop(VALUE self)
13193
13677
  VALUE
13194
13678
  Image_start_loop_eq(VALUE self, VALUE val)
13195
13679
  {
13196
- IMPLEMENT_ATTR_WRITER(Image, start_loop, boolean);
13680
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, start_loop, boolean, &rm_image_data_type);
13197
13681
  }
13198
13682
 
13199
13683
 
@@ -13225,7 +13709,8 @@ Image_stegano(VALUE self, VALUE watermark_image, VALUE offset)
13225
13709
  image->offset = NUM2LONG(offset);
13226
13710
 
13227
13711
  exception = AcquireExceptionInfo();
13228
- 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);
13229
13714
  rm_check_exception(exception, new_image, DestroyOnError);
13230
13715
 
13231
13716
  DestroyExceptionInfo(exception);
@@ -13257,7 +13742,8 @@ Image_stereo(VALUE self, VALUE offset_image_arg)
13257
13742
  offset = rm_check_destroyed(offset_image);
13258
13743
 
13259
13744
  exception = AcquireExceptionInfo();
13260
- 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);
13261
13747
  rm_check_exception(exception, new_image, DestroyOnError);
13262
13748
 
13263
13749
  DestroyExceptionInfo(exception);
@@ -13315,10 +13801,12 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
13315
13801
  if (image->storage_class == PseudoClass && class_type == DirectClass)
13316
13802
  {
13317
13803
  #if defined(IMAGEMAGICK_7)
13318
- SyncImage(image, exception);
13804
+ GVL_STRUCT_TYPE(SyncImage) args = { image, exception };
13805
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncImage), &args);
13319
13806
  CHECK_EXCEPTION();
13320
13807
  #else
13321
- SyncImage(image);
13808
+ GVL_STRUCT_TYPE(SyncImage) args = { image };
13809
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncImage), &args);
13322
13810
  #endif
13323
13811
  magick_free(image->colormap);
13324
13812
  image->colormap = NULL;
@@ -13328,19 +13816,23 @@ Image_class_type_eq(VALUE self, VALUE new_class_type)
13328
13816
  GetQuantizeInfo(&qinfo);
13329
13817
  qinfo.number_colors = QuantumRange+1;
13330
13818
  #if defined(IMAGEMAGICK_7)
13331
- QuantizeImage(&qinfo, image, exception);
13819
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &qinfo, image, exception };
13820
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
13332
13821
  CHECK_EXCEPTION();
13333
13822
  #else
13334
- QuantizeImage(&qinfo, image);
13823
+ GVL_STRUCT_TYPE(QuantizeImage) args = { &qinfo, image };
13824
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(QuantizeImage), &args);
13335
13825
  #endif
13336
13826
  }
13337
13827
 
13338
13828
  #if defined(IMAGEMAGICK_7)
13339
- SetImageStorageClass(image, class_type, exception);
13829
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, class_type, exception };
13830
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13340
13831
  CHECK_EXCEPTION();
13341
13832
  DestroyExceptionInfo(exception);
13342
13833
  #else
13343
- SetImageStorageClass(image, class_type);
13834
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, class_type };
13835
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13344
13836
  #endif
13345
13837
  return new_class_type;
13346
13838
  }
@@ -13369,7 +13861,7 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13369
13861
  long n, size;
13370
13862
  long x, y;
13371
13863
  unsigned long cols, rows;
13372
- unsigned int okay;
13864
+ MagickBooleanType okay;
13373
13865
  ExceptionInfo *exception;
13374
13866
  #if defined(IMAGEMAGICK_7)
13375
13867
  Quantum *pixels;
@@ -13395,7 +13887,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13395
13887
 
13396
13888
  #if defined(IMAGEMAGICK_7)
13397
13889
  exception = AcquireExceptionInfo();
13398
- 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);
13399
13892
  CHECK_EXCEPTION();
13400
13893
  if (!okay)
13401
13894
  {
@@ -13403,7 +13896,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13403
13896
  rb_raise(Class_ImageMagickError, "SetImageStorageClass failed. Can't store pixels.");
13404
13897
  }
13405
13898
  #else
13406
- okay = SetImageStorageClass(image, DirectClass);
13899
+ GVL_STRUCT_TYPE(SetImageStorageClass) args = { image, DirectClass };
13900
+ okay = (MagickBooleanType)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args);
13407
13901
  rm_check_image_exception(image, RetainOnError);
13408
13902
  if (!okay)
13409
13903
  {
@@ -13415,7 +13909,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13415
13909
  // Get a pointer to the pixels. Replace the values with the PixelPackets
13416
13910
  // from the pixels argument.
13417
13911
  {
13418
- 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);
13419
13914
  CHECK_EXCEPTION();
13420
13915
 
13421
13916
  if (pixels)
@@ -13431,7 +13926,7 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13431
13926
  DestroyExceptionInfo(exception);
13432
13927
  rb_raise(rb_eTypeError, "Item in array should be a Pixel.");
13433
13928
  }
13434
- Data_Get_Struct(new_pixel, Pixel, pixel);
13929
+ TypedData_Get_Struct(new_pixel, Pixel, &rm_pixel_data_type, pixel);
13435
13930
  #if defined(IMAGEMAGICK_7)
13436
13931
  SetPixelRed(image, pixel->red, pixels);
13437
13932
  SetPixelGreen(image, pixel->green, pixels);
@@ -13451,7 +13946,8 @@ Image_store_pixels(VALUE self, VALUE x_arg, VALUE y_arg, VALUE cols_arg,
13451
13946
  pixels++;
13452
13947
  #endif
13453
13948
  }
13454
- SyncAuthenticPixels(image, exception);
13949
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args = { image, exception };
13950
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args);
13455
13951
  CHECK_EXCEPTION();
13456
13952
  }
13457
13953
 
@@ -13511,10 +14007,11 @@ Image_swirl(VALUE self, VALUE degrees_obj)
13511
14007
  exception = AcquireExceptionInfo();
13512
14008
 
13513
14009
  #if defined(IMAGEMAGICK_7)
13514
- new_image = SwirlImage(image, degrees, image->interpolate, exception);
14010
+ GVL_STRUCT_TYPE(SwirlImage) args = { image, degrees, image->interpolate, exception };
13515
14011
  #else
13516
- new_image = SwirlImage(image, degrees, exception);
14012
+ GVL_STRUCT_TYPE(SwirlImage) args = { image, degrees, exception };
13517
14013
  #endif
14014
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SwirlImage), &args);
13518
14015
  rm_check_exception(exception, new_image, DestroyOnError);
13519
14016
  DestroyExceptionInfo(exception);
13520
14017
 
@@ -13605,12 +14102,14 @@ Image_texture_flood_fill(VALUE self, VALUE color_obj, VALUE texture_obj,
13605
14102
 
13606
14103
  #if defined(IMAGEMAGICK_7)
13607
14104
  exception = AcquireExceptionInfo();
13608
- 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);
13609
14107
  DestroyDrawInfo(draw_info);
13610
14108
  rm_check_exception(exception, new_image, DestroyOnError);
13611
14109
  DestroyExceptionInfo(exception);
13612
14110
  #else
13613
- 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);
13614
14113
 
13615
14114
  DestroyDrawInfo(draw_info);
13616
14115
  rm_check_image_exception(new_image, DestroyOnError);
@@ -13643,11 +14142,13 @@ Image_threshold(VALUE self, VALUE threshold_obj)
13643
14142
 
13644
14143
  #if defined(IMAGEMAGICK_7)
13645
14144
  exception = AcquireExceptionInfo();
13646
- BilevelImage(new_image, threshold, exception);
14145
+ GVL_STRUCT_TYPE(BilevelImage) args = { new_image, threshold, exception };
14146
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BilevelImage), &args);
13647
14147
  rm_check_exception(exception, new_image, DestroyOnError);
13648
14148
  DestroyExceptionInfo(exception);
13649
14149
  #else
13650
- BilevelImageChannel(new_image, DefaultChannels, threshold);
14150
+ GVL_STRUCT_TYPE(BilevelImageChannel) args = { new_image, DefaultChannels, threshold };
14151
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(BilevelImageChannel), &args);
13651
14152
  rm_check_image_exception(new_image, DestroyOnError);
13652
14153
  #endif
13653
14154
 
@@ -13655,6 +14156,9 @@ Image_threshold(VALUE self, VALUE threshold_obj)
13655
14156
  }
13656
14157
 
13657
14158
 
14159
+ // aliases for common use of structure types; WhiteThresholdImage
14160
+ typedef GVL_STRUCT_TYPE(WhiteThresholdImage) GVL_STRUCT_TYPE(threshold_image);
14161
+
13658
14162
  /**
13659
14163
  * Call one of the xxxxThresholdImage methods.
13660
14164
  *
@@ -13666,8 +14170,8 @@ Image_threshold(VALUE self, VALUE threshold_obj)
13666
14170
  * @param thresholder which xxxxThresholdImage method to call
13667
14171
  * @return a new image
13668
14172
  */
13669
- static
13670
- 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)
13671
14175
  {
13672
14176
  Image *image, *new_image;
13673
14177
  double red, green, blue, alpha;
@@ -13710,11 +14214,13 @@ VALUE threshold_image(int argc, VALUE *argv, VALUE self, thresholder_t threshold
13710
14214
 
13711
14215
  #if defined(IMAGEMAGICK_7)
13712
14216
  exception = AcquireExceptionInfo();
13713
- (thresholder)(new_image, ctarg, exception);
14217
+ GVL_STRUCT_TYPE(threshold_image) args = { new_image, ctarg, exception };
14218
+ CALL_FUNC_WITHOUT_GVL(fp, &args);
13714
14219
  rm_check_exception(exception, new_image, DestroyOnError);
13715
14220
  DestroyExceptionInfo(exception);
13716
14221
  #else
13717
- (thresholder)(new_image, ctarg);
14222
+ GVL_STRUCT_TYPE(threshold_image) args = { new_image, ctarg };
14223
+ CALL_FUNC_WITHOUT_GVL(fp, &args);
13718
14224
  rm_check_image_exception(new_image, DestroyOnError);
13719
14225
  #endif
13720
14226
 
@@ -13748,7 +14254,7 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
13748
14254
  RectangleInfo geometry;
13749
14255
  ExceptionInfo *exception;
13750
14256
 
13751
- Data_Get_Struct(self, Image, image);
14257
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
13752
14258
 
13753
14259
  switch (argc)
13754
14260
  {
@@ -13786,7 +14292,8 @@ thumbnail(int bang, int argc, VALUE *argv, VALUE self)
13786
14292
  ParseRegionGeometry(image, image_geometry, &geometry, exception);
13787
14293
  rm_check_exception(exception, image, RetainOnError);
13788
14294
 
13789
- 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);
13790
14297
  rm_check_exception(exception, new_image, DestroyOnError);
13791
14298
  DestroyExceptionInfo(exception);
13792
14299
 
@@ -13944,10 +14451,11 @@ Image_tint(int argc, VALUE *argv, VALUE self)
13944
14451
  exception = AcquireExceptionInfo();
13945
14452
 
13946
14453
  #if defined(IMAGEMAGICK_7)
13947
- new_image = TintImage(image, alpha, &tint, exception);
14454
+ GVL_STRUCT_TYPE(TintImage) args = { image, alpha, &tint, exception };
13948
14455
  #else
13949
- new_image = TintImage(image, alpha, tint, exception);
14456
+ GVL_STRUCT_TYPE(TintImage) args = { image, alpha, tint, exception };
13950
14457
  #endif
14458
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(TintImage), &args);
13951
14459
  rm_check_exception(exception, new_image, DestroyOnError);
13952
14460
  DestroyExceptionInfo(exception);
13953
14461
 
@@ -13980,7 +14488,7 @@ Image_to_blob(VALUE self)
13980
14488
  // both) and the image format by setting the depth and format
13981
14489
  // values in the info parm block.
13982
14490
  info_obj = rm_info_new();
13983
- Data_Get_Struct(info_obj, Info, info);
14491
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
13984
14492
 
13985
14493
  image = rm_check_destroyed(self);
13986
14494
 
@@ -13990,10 +14498,12 @@ Image_to_blob(VALUE self)
13990
14498
  if (info->depth != 0)
13991
14499
  {
13992
14500
  #if defined(IMAGEMAGICK_7)
13993
- SetImageDepth(image, info->depth, exception);
14501
+ GVL_STRUCT_TYPE(SetImageDepth) args = { image, info->depth, exception };
14502
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageDepth), &args);
13994
14503
  CHECK_EXCEPTION();
13995
14504
  #else
13996
- SetImageDepth(image, info->depth);
14505
+ GVL_STRUCT_TYPE(SetImageDepth) args = { image, info->depth };
14506
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageDepth), &args);
13997
14507
  rm_check_image_exception(image, RetainOnError);
13998
14508
  #endif
13999
14509
  }
@@ -14027,7 +14537,8 @@ Image_to_blob(VALUE self)
14027
14537
 
14028
14538
  rm_sync_image_options(image, info);
14029
14539
 
14030
- 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);
14031
14542
  CHECK_EXCEPTION();
14032
14543
 
14033
14544
  DestroyExceptionInfo(exception);
@@ -14173,11 +14684,13 @@ Image_transparent(int argc, VALUE *argv, VALUE self)
14173
14684
 
14174
14685
  #if defined(IMAGEMAGICK_7)
14175
14686
  exception = AcquireExceptionInfo();
14176
- 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);
14177
14689
  rm_check_exception(exception, new_image, DestroyOnError);
14178
14690
  DestroyExceptionInfo(exception);
14179
14691
  #else
14180
- 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);
14181
14694
  rm_check_image_exception(new_image, DestroyOnError);
14182
14695
  #endif
14183
14696
  if (!okay)
@@ -14247,11 +14760,13 @@ Image_transparent_chroma(int argc, VALUE *argv, VALUE self)
14247
14760
 
14248
14761
  #if defined(IMAGEMAGICK_7)
14249
14762
  exception = AcquireExceptionInfo();
14250
- 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);
14251
14765
  rm_check_exception(exception, new_image, DestroyOnError);
14252
14766
  DestroyExceptionInfo(exception);
14253
14767
  #else
14254
- 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);
14255
14770
  rm_check_image_exception(new_image, DestroyOnError);
14256
14771
  #endif
14257
14772
  if (!okay)
@@ -14304,7 +14819,7 @@ VALUE
14304
14819
  Image_transpose(VALUE self)
14305
14820
  {
14306
14821
  rm_check_destroyed(self);
14307
- return crisscross(False, self, TransposeImage);
14822
+ return crisscross(False, self, GVL_FUNC(TransposeImage));
14308
14823
  }
14309
14824
 
14310
14825
 
@@ -14320,7 +14835,7 @@ VALUE
14320
14835
  Image_transpose_bang(VALUE self)
14321
14836
  {
14322
14837
  rm_check_frozen(self);
14323
- return crisscross(True, self, TransposeImage);
14838
+ return crisscross(True, self, GVL_FUNC(TransposeImage));
14324
14839
  }
14325
14840
 
14326
14841
 
@@ -14335,7 +14850,7 @@ VALUE
14335
14850
  Image_transverse(VALUE self)
14336
14851
  {
14337
14852
  rm_check_destroyed(self);
14338
- return crisscross(False, self, TransverseImage);
14853
+ return crisscross(False, self, GVL_FUNC(TransverseImage));
14339
14854
  }
14340
14855
 
14341
14856
  /**
@@ -14350,7 +14865,7 @@ VALUE
14350
14865
  Image_transverse_bang(VALUE self)
14351
14866
  {
14352
14867
  rm_check_frozen(self);
14353
- return crisscross(True, self, TransverseImage);
14868
+ return crisscross(True, self, GVL_FUNC(TransverseImage));
14354
14869
  }
14355
14870
 
14356
14871
 
@@ -14388,10 +14903,11 @@ trimmer(int bang, int argc, VALUE *argv, VALUE self)
14388
14903
  break;
14389
14904
  }
14390
14905
 
14391
- Data_Get_Struct(self, Image, image);
14906
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
14392
14907
 
14393
14908
  exception = AcquireExceptionInfo();
14394
- 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);
14395
14911
  rm_check_exception(exception, new_image, DestroyOnError);
14396
14912
  DestroyExceptionInfo(exception);
14397
14913
 
@@ -14572,7 +15088,8 @@ Image_unique_colors(VALUE self)
14572
15088
  image = rm_check_destroyed(self);
14573
15089
  exception = AcquireExceptionInfo();
14574
15090
 
14575
- 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);
14576
15093
  rm_check_exception(exception, new_image, DestroyOnError);
14577
15094
  DestroyExceptionInfo(exception);
14578
15095
 
@@ -14738,7 +15255,8 @@ Image_unsharp_mask(int argc, VALUE *argv, VALUE self)
14738
15255
  unsharp_mask_args(argc, argv, &radius, &sigma, &amount, &threshold);
14739
15256
 
14740
15257
  exception = AcquireExceptionInfo();
14741
- 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);
14742
15260
  rm_check_exception(exception, new_image, DestroyOnError);
14743
15261
  DestroyExceptionInfo(exception);
14744
15262
 
@@ -14793,11 +15311,13 @@ Image_unsharp_mask_channel(int argc, VALUE *argv, VALUE self)
14793
15311
  exception = AcquireExceptionInfo();
14794
15312
  #if defined(IMAGEMAGICK_7)
14795
15313
  BEGIN_CHANNEL_MASK(image, channels);
14796
- 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);
14797
15316
  CHANGE_RESULT_CHANNEL_MASK(new_image);
14798
15317
  END_CHANNEL_MASK(image);
14799
15318
  #else
14800
- 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);
14801
15321
  #endif
14802
15322
  rm_check_exception(exception, new_image, DestroyOnError);
14803
15323
  DestroyExceptionInfo(exception);
@@ -14848,7 +15368,8 @@ Image_vignette(int argc, VALUE *argv, VALUE self)
14848
15368
 
14849
15369
  exception = AcquireExceptionInfo();
14850
15370
 
14851
- 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);
14852
15373
  rm_check_exception(exception, new_image, DestroyOnError);
14853
15374
  DestroyExceptionInfo(exception);
14854
15375
 
@@ -14994,11 +15515,13 @@ Image_watermark(int argc, VALUE *argv, VALUE self)
14994
15515
  new_image = rm_clone_image(image);
14995
15516
  #if defined(IMAGEMAGICK_7)
14996
15517
  exception = AcquireExceptionInfo();
14997
- 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);
14998
15520
  rm_check_exception(exception, new_image, DestroyOnError);
14999
15521
  DestroyExceptionInfo(exception);
15000
15522
  #else
15001
- 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);
15002
15525
 
15003
15526
  rm_check_image_exception(new_image, DestroyOnError);
15004
15527
  #endif
@@ -15041,10 +15564,11 @@ Image_wave(int argc, VALUE *argv, VALUE self)
15041
15564
 
15042
15565
  exception = AcquireExceptionInfo();
15043
15566
  #if defined(IMAGEMAGICK_7)
15044
- new_image = WaveImage(image, amplitude, wavelength, image->interpolate, exception);
15567
+ GVL_STRUCT_TYPE(WaveImage) args = { image, amplitude, wavelength, image->interpolate, exception };
15045
15568
  #else
15046
- new_image = WaveImage(image, amplitude, wavelength, exception);
15569
+ GVL_STRUCT_TYPE(WaveImage) args = { image, amplitude, wavelength, exception };
15047
15570
  #endif
15571
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WaveImage), &args);
15048
15572
  rm_check_exception(exception, new_image, DestroyOnError);
15049
15573
  DestroyExceptionInfo(exception);
15050
15574
 
@@ -15140,7 +15664,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15140
15664
 
15141
15665
 
15142
15666
  exception = AcquireExceptionInfo();
15143
- 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);
15144
15669
  CHECK_EXCEPTION();
15145
15670
 
15146
15671
 
@@ -15148,18 +15673,22 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15148
15673
  geometry.y = 0;
15149
15674
  geometry.width = image->columns;
15150
15675
  geometry.height = max_rows;
15151
- 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);
15152
15678
  DestroyImage(flip_image);
15153
15679
  CHECK_EXCEPTION();
15154
15680
 
15155
15681
 
15156
15682
  #if defined(IMAGEMAGICK_7)
15157
- SetImageStorageClass(reflection, DirectClass, exception);
15683
+ GVL_STRUCT_TYPE(SetImageStorageClass) args_SetImageStorageClass = { reflection, DirectClass, exception };
15684
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args_SetImageStorageClass);
15158
15685
  rm_check_exception(exception, reflection, DestroyOnError);
15159
- SetImageAlphaChannel(reflection, ActivateAlphaChannel, exception);
15686
+ GVL_STRUCT_TYPE(SetImageAlphaChannel) args_SetImageAlphaChannel = { reflection, ActivateAlphaChannel, exception };
15687
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageAlphaChannel), &args_SetImageAlphaChannel);
15160
15688
  rm_check_exception(exception, reflection, DestroyOnError);
15161
15689
  #else
15162
- SetImageStorageClass(reflection, DirectClass);
15690
+ GVL_STRUCT_TYPE(SetImageStorageClass) args_SetImageStorageClass = { reflection, DirectClass };
15691
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SetImageStorageClass), &args_SetImageStorageClass);
15163
15692
  rm_check_image_exception(reflection, DestroyOnError);
15164
15693
 
15165
15694
 
@@ -15181,7 +15710,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15181
15710
  }
15182
15711
  #endif
15183
15712
 
15184
- 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);
15185
15715
  rm_check_exception(exception, reflection, DestroyOnError);
15186
15716
  if (!p)
15187
15717
  {
@@ -15213,8 +15743,8 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15213
15743
  #endif
15214
15744
  }
15215
15745
 
15216
-
15217
- SyncAuthenticPixels(reflection, exception);
15746
+ GVL_STRUCT_TYPE(SyncAuthenticPixels) args_SyncAuthenticPixels = { reflection, exception };
15747
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(SyncAuthenticPixels), &args_SyncAuthenticPixels);
15218
15748
  rm_check_exception(exception, reflection, DestroyOnError);
15219
15749
 
15220
15750
  opacity += step;
@@ -15247,7 +15777,7 @@ Image_wet_floor(int argc, VALUE *argv, VALUE self)
15247
15777
  VALUE
15248
15778
  Image_white_threshold(int argc, VALUE *argv, VALUE self)
15249
15779
  {
15250
- return threshold_image(argc, argv, self, WhiteThresholdImage);
15780
+ return threshold_image(argc, argv, self, GVL_FUNC(WhiteThresholdImage));
15251
15781
  }
15252
15782
 
15253
15783
 
@@ -15360,7 +15890,7 @@ Image_write(VALUE self, VALUE file)
15360
15890
  image = rm_check_destroyed(self);
15361
15891
 
15362
15892
  info_obj = rm_info_new();
15363
- Data_Get_Struct(info_obj, Info, info);
15893
+ TypedData_Get_Struct(info_obj, Info, &rm_info_data_type, info);
15364
15894
 
15365
15895
  if (TYPE(file) == T_FILE)
15366
15896
  {
@@ -15390,11 +15920,13 @@ Image_write(VALUE self, VALUE file)
15390
15920
  info->adjoin = MagickFalse;
15391
15921
  #if defined(IMAGEMAGICK_7)
15392
15922
  exception = AcquireExceptionInfo();
15393
- WriteImage(info, image, exception);
15923
+ GVL_STRUCT_TYPE(WriteImage) args = { info, image, exception };
15924
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WriteImage), &args);
15394
15925
  CHECK_EXCEPTION();
15395
15926
  DestroyExceptionInfo(exception);
15396
15927
  #else
15397
- WriteImage(info, image);
15928
+ GVL_STRUCT_TYPE(WriteImage) args = { info, image };
15929
+ CALL_FUNC_WITHOUT_GVL(GVL_FUNC(WriteImage), &args);
15398
15930
  rm_check_image_exception(image, RetainOnError);
15399
15931
  #endif
15400
15932
 
@@ -15412,7 +15944,7 @@ Image_write(VALUE self, VALUE file)
15412
15944
  VALUE
15413
15945
  Image_x_resolution(VALUE self)
15414
15946
  {
15415
- IMPLEMENT_ATTR_READERF(Image, x_resolution, resolution.x, dbl);
15947
+ IMPLEMENT_TYPED_ATTR_READERF(Image, x_resolution, resolution.x, dbl, &rm_image_data_type);
15416
15948
  }
15417
15949
 
15418
15950
  /**
@@ -15424,7 +15956,7 @@ Image_x_resolution(VALUE self)
15424
15956
  VALUE
15425
15957
  Image_x_resolution_eq(VALUE self, VALUE val)
15426
15958
  {
15427
- IMPLEMENT_ATTR_WRITERF(Image, x_resolution, resolution.x, dbl);
15959
+ IMPLEMENT_TYPED_ATTR_WRITERF(Image, x_resolution, resolution.x, dbl, &rm_image_data_type);
15428
15960
  }
15429
15961
 
15430
15962
  /**
@@ -15435,7 +15967,7 @@ Image_x_resolution_eq(VALUE self, VALUE val)
15435
15967
  VALUE
15436
15968
  Image_y_resolution(VALUE self)
15437
15969
  {
15438
- IMPLEMENT_ATTR_READERF(Image, y_resolution, resolution.y, dbl);
15970
+ IMPLEMENT_TYPED_ATTR_READERF(Image, y_resolution, resolution.y, dbl, &rm_image_data_type);
15439
15971
  }
15440
15972
 
15441
15973
  /**
@@ -15447,7 +15979,7 @@ Image_y_resolution(VALUE self)
15447
15979
  VALUE
15448
15980
  Image_y_resolution_eq(VALUE self, VALUE val)
15449
15981
  {
15450
- IMPLEMENT_ATTR_WRITERF(Image, y_resolution, resolution.y, dbl);
15982
+ IMPLEMENT_TYPED_ATTR_WRITERF(Image, y_resolution, resolution.y, dbl, &rm_image_data_type);
15451
15983
  }
15452
15984
  #else
15453
15985
  /**
@@ -15458,7 +15990,7 @@ Image_y_resolution_eq(VALUE self, VALUE val)
15458
15990
  VALUE
15459
15991
  Image_x_resolution(VALUE self)
15460
15992
  {
15461
- IMPLEMENT_ATTR_READER(Image, x_resolution, dbl);
15993
+ IMPLEMENT_TYPED_ATTR_READER(Image, x_resolution, dbl, &rm_image_data_type);
15462
15994
  }
15463
15995
 
15464
15996
  /**
@@ -15470,7 +16002,7 @@ Image_x_resolution(VALUE self)
15470
16002
  VALUE
15471
16003
  Image_x_resolution_eq(VALUE self, VALUE val)
15472
16004
  {
15473
- IMPLEMENT_ATTR_WRITER(Image, x_resolution, dbl);
16005
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, x_resolution, dbl, &rm_image_data_type);
15474
16006
  }
15475
16007
 
15476
16008
  /**
@@ -15481,7 +16013,7 @@ Image_x_resolution_eq(VALUE self, VALUE val)
15481
16013
  VALUE
15482
16014
  Image_y_resolution(VALUE self)
15483
16015
  {
15484
- IMPLEMENT_ATTR_READER(Image, y_resolution, dbl);
16016
+ IMPLEMENT_TYPED_ATTR_READER(Image, y_resolution, dbl, &rm_image_data_type);
15485
16017
  }
15486
16018
 
15487
16019
  /**
@@ -15493,7 +16025,7 @@ Image_y_resolution(VALUE self)
15493
16025
  VALUE
15494
16026
  Image_y_resolution_eq(VALUE self, VALUE val)
15495
16027
  {
15496
- IMPLEMENT_ATTR_WRITER(Image, y_resolution, dbl);
16028
+ IMPLEMENT_TYPED_ATTR_WRITER(Image, y_resolution, dbl, &rm_image_data_type);
15497
16029
  }
15498
16030
  #endif
15499
16031
 
@@ -15552,7 +16084,7 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15552
16084
  switch (argc)
15553
16085
  {
15554
16086
  case 5:
15555
- Data_Get_Struct(self, Image, image);
16087
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
15556
16088
 
15557
16089
  VALUE_TO_ENUM(argv[0], gravity, GravityType);
15558
16090
 
@@ -15619,7 +16151,7 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15619
16151
  columns = NUM2ULONG(width);
15620
16152
  rows = NUM2ULONG(height);
15621
16153
 
15622
- Data_Get_Struct(self, Image, image);
16154
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
15623
16155
 
15624
16156
  switch (gravity)
15625
16157
  {
@@ -15682,10 +16214,10 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15682
16214
  break;
15683
16215
  }
15684
16216
 
15685
- cropped = xform_image(bang, self, x, y, width, height, CropImage);
16217
+ cropped = xform_image(bang, self, x, y, width, height, GVL_FUNC(CropImage));
15686
16218
  if (reset_page)
15687
16219
  {
15688
- Data_Get_Struct(cropped, Image, image);
16220
+ TypedData_Get_Struct(cropped, Image, &rm_image_data_type, image);
15689
16221
  ResetImagePage(image, "0x0+0+0");
15690
16222
  }
15691
16223
 
@@ -15698,6 +16230,9 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15698
16230
  }
15699
16231
 
15700
16232
 
16233
+ // aliases for common use of structure types; ChopImage, CropImage, ShaveImage
16234
+ typedef GVL_STRUCT_TYPE(ChopImage) GVL_STRUCT_TYPE(xform_image);
16235
+
15701
16236
  /**
15702
16237
  * Call one of the image transformation functions.
15703
16238
  *
@@ -15713,13 +16248,13 @@ cropper(int bang, int argc, VALUE *argv, VALUE self)
15713
16248
  * @return self if bang, otherwise a new image
15714
16249
  */
15715
16250
  static VALUE
15716
- xform_image(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, xformer_t xformer)
16251
+ xform_image(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, gvl_function_t fp)
15717
16252
  {
15718
16253
  Image *image, *new_image;
15719
16254
  RectangleInfo rect;
15720
16255
  ExceptionInfo *exception;
15721
16256
 
15722
- Data_Get_Struct(self, Image, image);
16257
+ TypedData_Get_Struct(self, Image, &rm_image_data_type, image);
15723
16258
  rect.x = NUM2LONG(x);
15724
16259
  rect.y = NUM2LONG(y);
15725
16260
  rect.width = NUM2ULONG(width);
@@ -15727,7 +16262,8 @@ xform_image(int bang, VALUE self, VALUE x, VALUE y, VALUE width, VALUE height, x
15727
16262
 
15728
16263
  exception = AcquireExceptionInfo();
15729
16264
 
15730
- new_image = (xformer)(image, &rect, exception);
16265
+ GVL_STRUCT_TYPE(xform_image) args = { image, &rect, exception };
16266
+ new_image = (Image *)CALL_FUNC_WITHOUT_GVL(fp, &args);
15731
16267
 
15732
16268
  // An exception can occur in either the old or the new images
15733
16269
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -15813,75 +16349,6 @@ raise_ChannelType_error(VALUE arg)
15813
16349
  }
15814
16350
 
15815
16351
 
15816
-
15817
- /**
15818
- * If Magick.trace_proc is not nil, build an argument list and call the proc.
15819
- *
15820
- * No Ruby usage (internal function)
15821
- *
15822
- * @param image the image
15823
- * @param which which operation the proc is being called for
15824
- */
15825
- static void call_trace_proc(Image *image, const char *which)
15826
- {
15827
- VALUE trace;
15828
- VALUE trace_args[4];
15829
-
15830
- if (rb_ivar_defined(Module_Magick, rm_ID_trace_proc) == Qtrue)
15831
- {
15832
- trace = rb_ivar_get(Module_Magick, rm_ID_trace_proc);
15833
- if (!NIL_P(trace))
15834
- {
15835
- // Maybe the stack won't get extended until we need the space.
15836
- char buffer[MaxTextExtent];
15837
-
15838
- trace_args[0] = ID2SYM(rb_intern(which));
15839
-
15840
- build_inspect_string(image, buffer, sizeof(buffer));
15841
- trace_args[1] = rb_str_new2(buffer);
15842
-
15843
- snprintf(buffer, sizeof(buffer), "%p", (void *)image);
15844
- trace_args[2] = rb_str_new2(buffer+2); // don't use leading 0x
15845
- trace_args[3] = ID2SYM(rb_frame_this_func());
15846
- rb_funcall2(trace, rm_ID_call, 4, (VALUE *)trace_args);
15847
- }
15848
- }
15849
-
15850
- RB_GC_GUARD(trace);
15851
- }
15852
-
15853
-
15854
- static VALUE
15855
- rm_trace_creation_body(VALUE img)
15856
- {
15857
- Image *image = (Image *)img;
15858
- call_trace_proc(image, "c");
15859
- return Qnil;
15860
- }
15861
-
15862
- static VALUE
15863
- rm_trace_creation_handle_exception(VALUE img, VALUE exc)
15864
- {
15865
- Image *image = (Image *)img;
15866
- DestroyImage(image);
15867
- rb_exc_raise(exc);
15868
- }
15869
-
15870
- /**
15871
- * Trace image creation
15872
- *
15873
- * No Ruby usage (internal function)
15874
- *
15875
- * @param image the image
15876
- * @see call_trace_proc
15877
- */
15878
- void rm_trace_creation(Image *image)
15879
- {
15880
- rb_rescue(rm_trace_creation_body, (VALUE)image, rm_trace_creation_handle_exception, (VALUE)image);
15881
- }
15882
-
15883
-
15884
-
15885
16352
  /**
15886
16353
  * Destroy an image. Called from GC when all references to the image have gone
15887
16354
  * out of scope.
@@ -15900,9 +16367,19 @@ void rm_image_destroy(void *img)
15900
16367
 
15901
16368
  if (img != NULL)
15902
16369
  {
15903
- call_trace_proc(image, "d");
15904
16370
  DestroyImage(image);
15905
16371
  }
15906
16372
  }
15907
16373
 
15908
-
16374
+ /**
16375
+ * Get Image object size.
16376
+ *
16377
+ * No Ruby usage (internal function)
16378
+ *
16379
+ * @param ptr pointer to the Image object
16380
+ */
16381
+ static size_t
16382
+ rm_image_memsize(const void *ptr)
16383
+ {
16384
+ return sizeof(Image);
16385
+ }