rmagick 3.0.0 → 3.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.

Files changed (57) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +32 -6
  3. data/.circleci/config.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop.yml +9 -9
  6. data/.rubocop_todo.yml +351 -17
  7. data/.travis.yml +14 -1
  8. data/CHANGELOG.md +55 -0
  9. data/CONTRIBUTING.md +11 -18
  10. data/README.textile +2 -2
  11. data/Rakefile +1 -1
  12. data/before_install_linux.sh +56 -19
  13. data/doc/ex/sparse_color.rb +5 -0
  14. data/doc/magick.html +9 -4
  15. data/doc/rvg.html +2 -2
  16. data/doc/rvgtut.html +1 -1
  17. data/examples/histogram.rb +1 -1
  18. data/ext/RMagick/extconf.rb +90 -264
  19. data/ext/RMagick/rmagick.c +28 -6
  20. data/ext/RMagick/rmagick.h +53 -199
  21. data/ext/RMagick/rmdraw.c +52 -70
  22. data/ext/RMagick/rmenum.c +332 -274
  23. data/ext/RMagick/rmfill.c +62 -112
  24. data/ext/RMagick/rmilist.c +27 -62
  25. data/ext/RMagick/rmimage.c +424 -634
  26. data/ext/RMagick/rminfo.c +46 -37
  27. data/ext/RMagick/rmkinfo.c +47 -42
  28. data/ext/RMagick/rmmain.c +125 -180
  29. data/ext/RMagick/rmmontage.c +5 -5
  30. data/ext/RMagick/rmpixel.c +133 -62
  31. data/ext/RMagick/rmstruct.c +14 -181
  32. data/ext/RMagick/rmutil.c +195 -111
  33. data/lib/rmagick/version.rb +2 -3
  34. data/lib/rvg/deep_equal.rb +1 -1
  35. data/lib/rvg/misc.rb +4 -4
  36. data/lib/rvg/units.rb +2 -2
  37. data/rmagick.gemspec +2 -2
  38. data/spec/rmagick/ImageList1_spec.rb +2 -2
  39. data/spec/rmagick/draw_spec.rb +4 -4
  40. data/spec/rmagick/image/composite_spec.rb +6 -1
  41. data/spec/rmagick/image/properties_spec.rb +8 -8
  42. data/test/Draw.rb +414 -0
  43. data/test/Enum.rb +76 -0
  44. data/test/Fill.rb +93 -0
  45. data/test/Image1.rb +9 -1
  46. data/test/Image2.rb +14 -4
  47. data/test/Image3.rb +73 -3
  48. data/test/ImageList1.rb +22 -9
  49. data/test/ImageList2.rb +41 -9
  50. data/test/Image_attributes.rb +45 -8
  51. data/test/Info.rb +102 -6
  52. data/test/Magick.rb +8 -1
  53. data/test/PolaroidOptions.rb +23 -0
  54. data/test/test_all_basic.rb +4 -0
  55. metadata +28 -8
  56. data/.hound.yml +0 -2
  57. data/wercker.yml +0 -10
@@ -19,8 +19,8 @@ typedef struct
19
19
  double y1; /**< y position of first point */
20
20
  double x2; /**< x position of second point */
21
21
  double y2; /**< y position of second point */
22
- PixelPacket start_color; /**< the start color */
23
- PixelPacket stop_color; /**< the stop color */
22
+ PixelColor start_color; /**< the start color */
23
+ PixelColor stop_color; /**< the stop color */
24
24
  } rm_GradientFill;
25
25
 
26
26
  /** Data associated with a TextureFill */
@@ -91,8 +91,8 @@ GradientFill_initialize(
91
91
  fill->y1 = NUM2DBL(y1);
92
92
  fill->x2 = NUM2DBL(x2);
93
93
  fill->y2 = NUM2DBL(y2);
94
- Color_to_PixelPacket(&fill->start_color, start_color);
95
- Color_to_PixelPacket(&fill->stop_color, stop_color);
94
+ Color_to_PixelColor(&fill->start_color, start_color);
95
+ Color_to_PixelColor(&fill->stop_color, stop_color);
96
96
 
97
97
  return self;
98
98
  }
@@ -113,17 +113,15 @@ point_fill(
113
113
  Image *image,
114
114
  double x0,
115
115
  double y0,
116
- PixelPacket *start_color,
117
- PixelPacket *stop_color)
116
+ PixelColor *start_color,
117
+ PixelColor *stop_color)
118
118
  {
119
119
  double steps, distance;
120
- unsigned long x, y;
120
+ ssize_t x, y;
121
121
  MagickRealType red_step, green_step, blue_step;
122
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
123
122
  ExceptionInfo *exception;
124
123
 
125
124
  exception = AcquireExceptionInfo();
126
- #endif
127
125
 
128
126
  steps = sqrt((double)((image->columns-x0)*(image->columns-x0)
129
127
  + (image->rows-y0)*(image->rows-y0)));
@@ -132,18 +130,14 @@ point_fill(
132
130
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
133
131
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
134
132
 
135
- for (y = 0; y < image->rows; y++)
133
+ for (y = 0; y < (ssize_t) image->rows; y++)
136
134
  {
137
135
  PixelPacket *row_pixels;
138
136
 
139
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
140
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
137
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
141
138
  CHECK_EXCEPTION()
142
- #else
143
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
144
- rm_check_image_exception(image, RetainOnError);
145
- #endif
146
- for (x = 0; x < image->columns; x++)
139
+
140
+ for (x = 0; x < (ssize_t) image->columns; x++)
147
141
  {
148
142
  distance = sqrt((double)((x-x0)*(x-x0)+(y-y0)*(y-y0)));
149
143
  row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
@@ -152,18 +146,11 @@ point_fill(
152
146
  row_pixels[x].opacity = OpaqueOpacity;
153
147
  }
154
148
 
155
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
156
149
  SyncAuthenticPixels(image, exception);
157
150
  CHECK_EXCEPTION()
158
- #else
159
- SyncImagePixels(image);
160
- rm_check_image_exception(image, RetainOnError);
161
- #endif
162
151
  }
163
152
 
164
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
165
153
  DestroyExceptionInfo(exception);
166
- #endif
167
154
  }
168
155
 
169
156
  /**
@@ -181,18 +168,16 @@ static void
181
168
  vertical_fill(
182
169
  Image *image,
183
170
  double x1,
184
- PixelPacket *start_color,
185
- PixelPacket *stop_color)
171
+ PixelColor *start_color,
172
+ PixelColor *stop_color)
186
173
  {
187
174
  double steps;
188
- unsigned long x, y;
175
+ ssize_t x, y;
189
176
  PixelPacket *master;
190
177
  MagickRealType red_step, green_step, blue_step;
191
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
192
178
  ExceptionInfo *exception;
193
179
 
194
180
  exception = AcquireExceptionInfo();
195
- #endif
196
181
 
197
182
  steps = FMAX(x1, ((long)image->columns)-x1);
198
183
 
@@ -212,7 +197,7 @@ vertical_fill(
212
197
  // it to each actual row.
213
198
  master = ALLOC_N(PixelPacket, image->columns);
214
199
 
215
- for (x = 0; x < image->columns; x++)
200
+ for (x = 0; x < (ssize_t) image->columns; x++)
216
201
  {
217
202
  double distance = fabs(x1 - x);
218
203
  master[x].red = ROUND_TO_QUANTUM(start_color->red + (red_step * distance));
@@ -222,32 +207,28 @@ vertical_fill(
222
207
  }
223
208
 
224
209
  // Now copy the master row to each actual row.
225
- for (y = 0; y < image->rows; y++)
210
+ for (y = 0; y < (ssize_t) image->rows; y++)
226
211
  {
227
212
  PixelPacket *row_pixels;
228
213
 
229
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
230
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
231
- CHECK_EXCEPTION()
232
- #else
233
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
234
- rm_check_image_exception(image, RetainOnError);
235
- #endif
214
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
215
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
216
+ {
217
+ xfree((void *)master);
218
+ rm_raise_exception(exception);
219
+ }
236
220
 
237
221
  memcpy(row_pixels, master, image->columns * sizeof(PixelPacket));
238
222
 
239
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
240
223
  SyncAuthenticPixels(image, exception);
241
- CHECK_EXCEPTION()
242
- #else
243
- SyncImagePixels(image);
244
- rm_check_image_exception(image, RetainOnError);
245
- #endif
224
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
225
+ {
226
+ xfree((void *)master);
227
+ rm_raise_exception(exception);
228
+ }
246
229
  }
247
230
 
248
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
249
231
  DestroyExceptionInfo(exception);
250
- #endif
251
232
 
252
233
  xfree((void *)master);
253
234
  }
@@ -266,18 +247,16 @@ static void
266
247
  horizontal_fill(
267
248
  Image *image,
268
249
  double y1,
269
- PixelPacket *start_color,
270
- PixelPacket *stop_color)
250
+ PixelColor *start_color,
251
+ PixelColor *stop_color)
271
252
  {
272
253
  double steps;
273
- unsigned long x, y;
254
+ ssize_t x, y;
274
255
  PixelPacket *master;
275
256
  MagickRealType red_step, green_step, blue_step;
276
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
277
257
  ExceptionInfo *exception;
278
258
 
279
259
  exception = AcquireExceptionInfo();
280
- #endif
281
260
 
282
261
  steps = FMAX(y1, ((long)image->rows)-y1);
283
262
 
@@ -296,7 +275,7 @@ horizontal_fill(
296
275
  // each of the "real" columns.
297
276
  master = ALLOC_N(PixelPacket, image->rows);
298
277
 
299
- for (y = 0; y < image->rows; y++)
278
+ for (y = 0; y < (ssize_t) image->rows; y++)
300
279
  {
301
280
  double distance = fabs(y1 - y);
302
281
  master[y].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
@@ -305,32 +284,30 @@ horizontal_fill(
305
284
  master[y].opacity = OpaqueOpacity;
306
285
  }
307
286
 
308
- for (x = 0; x < image->columns; x++)
287
+ for (x = 0; x < (ssize_t) image->columns; x++)
309
288
  {
310
289
  PixelPacket *col_pixels;
311
290
 
312
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
313
- col_pixels = QueueAuthenticPixels(image, (long int)x, 0, 1, image->rows, exception);
314
- #else
315
- col_pixels = SetImagePixels(image, (long int)x, 0, 1, image->rows);
316
- rm_check_image_exception(image, RetainOnError);
317
- #endif
291
+ col_pixels = QueueAuthenticPixels(image, x, 0, 1, image->rows, exception);
292
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
293
+ {
294
+ xfree((void *)master);
295
+ rm_raise_exception(exception);
296
+ }
297
+
318
298
  memcpy(col_pixels, master, image->rows * sizeof(PixelPacket));
319
299
 
320
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
321
300
  SyncAuthenticPixels(image, exception);
322
- CHECK_EXCEPTION()
323
- #else
324
- SyncImagePixels(image);
325
- rm_check_image_exception(image, RetainOnError);
326
- #endif
301
+ if (rm_should_raise_exception(exception, RetainExceptionRetention))
302
+ {
303
+ xfree((void *)master);
304
+ rm_raise_exception(exception);
305
+ }
327
306
  }
328
307
 
329
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
330
308
  DestroyExceptionInfo(exception);
331
- #endif
332
309
 
333
- xfree((PixelPacket *)master);
310
+ xfree((void *)master);
334
311
  }
335
312
 
336
313
  /**
@@ -354,18 +331,16 @@ v_diagonal_fill(
354
331
  double y1,
355
332
  double x2,
356
333
  double y2,
357
- PixelPacket *start_color,
358
- PixelPacket *stop_color)
334
+ PixelColor *start_color,
335
+ PixelColor *stop_color)
359
336
  {
360
- unsigned long x, y;
337
+ ssize_t x, y;
361
338
  MagickRealType red_step, green_step, blue_step;
362
339
  double m, b, steps = 0.0;
363
340
  double d1, d2;
364
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
365
341
  ExceptionInfo *exception;
366
342
 
367
343
  exception = AcquireExceptionInfo();
368
- #endif
369
344
 
370
345
  // Compute the equation of the line: y=mx+b
371
346
  m = ((double)(y2 - y1))/((double)(x2 - x1));
@@ -393,7 +368,7 @@ v_diagonal_fill(
393
368
  // If the line is entirely > image->rows, swap the start & end color
394
369
  if (steps < 0)
395
370
  {
396
- PixelPacket t = *stop_color;
371
+ PixelColor t = *stop_color;
397
372
  *stop_color = *start_color;
398
373
  *start_color = t;
399
374
  steps = -steps;
@@ -403,18 +378,14 @@ v_diagonal_fill(
403
378
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
404
379
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
405
380
 
406
- for (y = 0; y < image->rows; y++)
381
+ for (y = 0; y < (ssize_t) image->rows; y++)
407
382
  {
408
383
  PixelPacket *row_pixels;
409
384
 
410
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
411
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
385
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
412
386
  CHECK_EXCEPTION()
413
- #else
414
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
415
- rm_check_image_exception(image, RetainOnError);
416
- #endif
417
- for (x = 0; x < image->columns; x++)
387
+
388
+ for (x = 0; x < (ssize_t) image->columns; x++)
418
389
  {
419
390
  double distance = (double) abs((int)(y-(m * x + b)));
420
391
  row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
@@ -423,19 +394,11 @@ v_diagonal_fill(
423
394
  row_pixels[x].opacity = OpaqueOpacity;
424
395
  }
425
396
 
426
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
427
397
  SyncAuthenticPixels(image, exception);
428
398
  CHECK_EXCEPTION()
429
- #else
430
- SyncImagePixels(image);
431
- rm_check_image_exception(image, RetainOnError);
432
- #endif
433
399
  }
434
400
 
435
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
436
401
  DestroyExceptionInfo(exception);
437
- #endif
438
-
439
402
  }
440
403
 
441
404
  /**
@@ -459,18 +422,16 @@ h_diagonal_fill(
459
422
  double y1,
460
423
  double x2,
461
424
  double y2,
462
- PixelPacket *start_color,
463
- PixelPacket *stop_color)
425
+ PixelColor *start_color,
426
+ PixelColor *stop_color)
464
427
  {
465
- unsigned long x, y;
428
+ ssize_t x, y;
466
429
  double m, b, steps = 0.0;
467
430
  MagickRealType red_step, green_step, blue_step;
468
431
  double d1, d2;
469
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
470
432
  ExceptionInfo *exception;
471
433
 
472
434
  exception = AcquireExceptionInfo();
473
- #endif
474
435
 
475
436
  // Compute the equation of the line: y=mx+b
476
437
  m = ((double)(y2 - y1))/((double)(x2 - x1));
@@ -500,7 +461,7 @@ h_diagonal_fill(
500
461
  // If the line is entirely > image->columns, swap the start & end color
501
462
  if (steps < 0)
502
463
  {
503
- PixelPacket t = *stop_color;
464
+ PixelColor t = *stop_color;
504
465
  *stop_color = *start_color;
505
466
  *start_color = t;
506
467
  steps = -steps;
@@ -510,18 +471,14 @@ h_diagonal_fill(
510
471
  green_step = ((MagickRealType)stop_color->green - (MagickRealType)start_color->green) / steps;
511
472
  blue_step = ((MagickRealType)stop_color->blue - (MagickRealType)start_color->blue) / steps;
512
473
 
513
- for (y = 0; y < image->rows; y++)
474
+ for (y = 0; y < (ssize_t) image->rows; y++)
514
475
  {
515
476
  PixelPacket *row_pixels;
516
477
 
517
- #if defined(HAVE_QUEUEAUTHENTICPIXELS)
518
- row_pixels = QueueAuthenticPixels(image, 0, (long int)y, image->columns, 1, exception);
478
+ row_pixels = QueueAuthenticPixels(image, 0, y, image->columns, 1, exception);
519
479
  CHECK_EXCEPTION()
520
- #else
521
- row_pixels = SetImagePixels(image, 0, (long int)y, image->columns, 1);
522
- rm_check_image_exception(image, RetainOnError);
523
- #endif
524
- for (x = 0; x < image->columns; x++)
480
+
481
+ for (x = 0; x < (ssize_t) image->columns; x++)
525
482
  {
526
483
  double distance = (double) abs((int)(x-((y-b)/m)));
527
484
  row_pixels[x].red = ROUND_TO_QUANTUM(start_color->red + (distance * red_step));
@@ -530,18 +487,11 @@ h_diagonal_fill(
530
487
  row_pixels[x].opacity = OpaqueOpacity;
531
488
  }
532
489
 
533
- #if defined(HAVE_SYNCAUTHENTICPIXELS)
534
490
  SyncAuthenticPixels(image, exception);
535
491
  CHECK_EXCEPTION()
536
- #else
537
- SyncImagePixels(image);
538
- rm_check_image_exception(image, RetainOnError);
539
- #endif
540
492
  }
541
493
 
542
- #if defined(HAVE_SYNCAUTHENTICPIXELS) || defined(HAVE_QUEUEAUTHENTICPIXELS)
543
494
  DestroyExceptionInfo(exception);
544
- #endif
545
495
  }
546
496
 
547
497
  /**
@@ -560,7 +510,7 @@ GradientFill_fill(VALUE self, VALUE image_obj)
560
510
  {
561
511
  rm_GradientFill *fill;
562
512
  Image *image;
563
- PixelPacket start_color, stop_color;
513
+ PixelColor start_color, stop_color;
564
514
  double x1, y1, x2, y2; // points on the line
565
515
 
566
516
  Data_Get_Struct(self, rm_GradientFill, fill);
@@ -45,7 +45,12 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
45
45
  Image *images;
46
46
  Info *info;
47
47
  VALUE info_obj;
48
+ unsigned int delay;
48
49
 
50
+ if (argc == 1)
51
+ {
52
+ delay = NUM2UINT(argv[0]);
53
+ }
49
54
  if (argc > 1)
50
55
  {
51
56
  rb_raise(rb_eArgError, "wrong number of arguments (%d for 0 or 1)", argc);
@@ -60,9 +65,7 @@ ImageList_animate(int argc, VALUE *argv, VALUE self)
60
65
  if (argc == 1)
61
66
  {
62
67
  Image *img;
63
- unsigned int delay;
64
68
 
65
- delay = NUM2UINT(argv[0]);
66
69
  for (img = images; img; img = GetNextImageInList(img))
67
70
  {
68
71
  img->delay = delay;
@@ -135,11 +138,7 @@ ImageList_average(VALUE self)
135
138
  images = images_from_imagelist(self);
136
139
 
137
140
  exception = AcquireExceptionInfo();
138
- #if defined(HAVE_EVALUATEIMAGES)
139
141
  new_image = EvaluateImages(images, MeanEvaluateOperator, exception);
140
- #else
141
- new_image = AverageImages(images, exception);
142
- #endif
143
142
 
144
143
  rm_split(images);
145
144
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -333,11 +332,7 @@ ImageList_flatten_images(VALUE self)
333
332
  images = images_from_imagelist(self);
334
333
  exception = AcquireExceptionInfo();
335
334
 
336
- #if defined(HAVE_ENUM_FLATTENLAYER)
337
335
  new_image = MergeImageLayers(images, FlattenLayer, exception);
338
- #else
339
- new_image = FlattenImages(images, exception);
340
- #endif
341
336
 
342
337
  rm_split(images);
343
338
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -364,6 +359,7 @@ ImageList_flatten_images(VALUE self)
364
359
  * @param argv array of input arguments
365
360
  * @param self this object
366
361
  * @return a new image
362
+ * @deprecated This method has been deprecated. Please use Image_fx.
367
363
  */
368
364
  VALUE
369
365
  ImageList_fx(int argc, VALUE *argv, VALUE self)
@@ -373,6 +369,7 @@ ImageList_fx(int argc, VALUE *argv, VALUE self)
373
369
  ChannelType channels;
374
370
  ExceptionInfo *exception;
375
371
 
372
+ rb_warning("ImageList#fx is deprecated; use Image#fx");
376
373
 
377
374
  channels = extract_channels(&argc, argv);
378
375
 
@@ -426,10 +423,8 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
426
423
  VALUE scene, new_imagelist, t;
427
424
  ExceptionInfo *exception;
428
425
 
429
- #if defined(HAVE_REMAPIMAGES)
430
426
  QuantizeInfo quantize_info;
431
427
  rb_warning("ImageList#map is deprecated. Use ImageList#remap instead.");
432
- #endif
433
428
 
434
429
  switch (argc)
435
430
  {
@@ -446,9 +441,9 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
446
441
 
447
442
 
448
443
  // Convert image array to image sequence, clone image sequence.
449
- exception = AcquireExceptionInfo();
450
-
451
444
  images = images_from_imagelist(self);
445
+
446
+ exception = AcquireExceptionInfo();
452
447
  new_images = CloneImageList(images, exception);
453
448
  rm_split(images);
454
449
  rm_check_exception(exception, new_images, DestroyOnError);
@@ -457,13 +452,9 @@ ImageList_map(int argc, VALUE *argv, VALUE self)
457
452
  rm_ensure_result(new_images);
458
453
 
459
454
  // Call ImageMagick
460
- #if defined(HAVE_REMAPIMAGES)
461
455
  GetQuantizeInfo(&quantize_info);
462
456
  quantize_info.dither = dither;
463
457
  (void) RemapImages(&quantize_info, new_images, map);
464
- #else
465
- (void) MapImages(new_images, map, dither);
466
- #endif
467
458
  rm_check_image_exception(new_images, DestroyOnError);
468
459
 
469
460
  // Set @scene in new ImageList object to same value as in self.
@@ -568,8 +559,8 @@ ImageList_morph(VALUE self, VALUE nimages)
568
559
  rb_raise(rb_eArgError, "number of intervening images must be > 0");
569
560
  }
570
561
 
571
- exception = AcquireExceptionInfo();
572
562
  images = images_from_imagelist(self);
563
+ exception = AcquireExceptionInfo();
573
564
  new_images = MorphImages(images, (unsigned long)number_images, exception);
574
565
  rm_split(images);
575
566
  rm_check_exception(exception, new_images, DestroyOnError);
@@ -596,14 +587,10 @@ ImageList_mosaic(VALUE self)
596
587
  Image *images, *new_image;
597
588
  ExceptionInfo *exception;
598
589
 
599
- exception = AcquireExceptionInfo();
600
590
  images = images_from_imagelist(self);
601
591
 
602
- #if defined(HAVE_ENUM_MOSAICLAYER)
592
+ exception = AcquireExceptionInfo();
603
593
  new_image = MergeImageLayers(images, MosaicLayer, exception);
604
- #else
605
- new_image = MosaicImages(images, exception);
606
- #endif
607
594
 
608
595
  rm_split(images);
609
596
  rm_check_exception(exception, new_image, DestroyOnError);
@@ -629,20 +616,16 @@ VALUE
629
616
  ImageList_optimize_layers(VALUE self, VALUE method)
630
617
  {
631
618
  Image *images, *new_images, *new_images2;
632
- LAYERMETHODTYPE mthd;
619
+ ImageLayerMethod mthd;
633
620
  ExceptionInfo *exception;
634
621
  QuantizeInfo quantize_info;
635
622
 
636
623
  new_images2 = NULL; // defeat "unused variable" message
637
624
 
638
- exception = AcquireExceptionInfo();
639
- #if defined(HAVE_TYPE_IMAGELAYERMETHOD)
640
625
  VALUE_TO_ENUM(method, mthd, ImageLayerMethod);
641
- #else
642
- VALUE_TO_ENUM(method, mthd, MagickLayerMethod);
643
- #endif
644
626
  images = images_from_imagelist(self);
645
627
 
628
+ exception = AcquireExceptionInfo();
646
629
  switch (mthd)
647
630
  {
648
631
  case CoalesceLayer:
@@ -665,6 +648,7 @@ ImageList_optimize_layers(VALUE self, VALUE method)
665
648
  break;
666
649
  case CompositeLayer:
667
650
  rm_split(images);
651
+ (void) DestroyExceptionInfo(exception);
668
652
  rb_raise(rb_eNotImpError, "Magick::CompositeLayer is not supported. Use the composite_layers method instead.");
669
653
  break;
670
654
  // In 6.3.4-ish, OptimizeImageLayer replaced OptimizeLayer
@@ -683,12 +667,8 @@ ImageList_optimize_layers(VALUE self, VALUE method)
683
667
  OptimizeImageTransparency(new_images, exception);
684
668
  rm_check_exception(exception, new_images, DestroyOnError);
685
669
  // mogrify supports -dither here. We don't.
686
- #if defined(HAVE_REMAPIMAGE)
687
670
  GetQuantizeInfo(&quantize_info);
688
671
  (void) RemapImages(&quantize_info, new_images, NULL);
689
- #else
690
- (void) MapImages(new_images, NULL, 0);
691
- #endif
692
672
  break;
693
673
  case OptimizePlusLayer:
694
674
  new_images = OptimizePlusImageLayers(images, exception);
@@ -698,28 +678,21 @@ ImageList_optimize_layers(VALUE self, VALUE method)
698
678
  case CompareOverlayLayer:
699
679
  new_images = CompareImageLayers(images, mthd, exception);
700
680
  break;
701
- #if defined(HAVE_ENUM_MOSAICLAYER)
702
681
  case MosaicLayer:
703
682
  new_images = MergeImageLayers(images, mthd, exception);
704
683
  break;
705
- #endif
706
- #if defined(HAVE_ENUM_FLATTENLAYER)
707
684
  case FlattenLayer:
708
685
  new_images = MergeImageLayers(images, mthd, exception);
709
686
  break;
710
- #endif
711
- #if defined(HAVE_ENUM_MERGELAYER)
712
687
  case MergeLayer:
713
688
  new_images = MergeImageLayers(images, mthd, exception);
714
689
  break;
715
- #endif
716
- #if defined(HAVE_ENUM_TRIMBOUNDSLAYER)
717
690
  case TrimBoundsLayer:
718
691
  new_images = MergeImageLayers(images, mthd, exception);
719
692
  break;
720
- #endif
721
693
  default:
722
694
  rm_split(images);
695
+ (void) DestroyExceptionInfo(exception);
723
696
  rb_raise(rb_eArgError, "undefined layer method");
724
697
  break;
725
698
  }
@@ -861,6 +834,10 @@ static long
861
834
  imagelist_length(VALUE imagelist)
862
835
  {
863
836
  VALUE images = rb_iv_get(imagelist, "@images");
837
+ if (!RB_TYPE_P(images, T_ARRAY))
838
+ {
839
+ rb_raise(Class_ImageMagickError, "@images is not of type Array");
840
+ }
864
841
 
865
842
  RB_GC_GUARD(images);
866
843
 
@@ -979,15 +956,15 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
979
956
  case 4:
980
957
  quantize_info.tree_depth = (unsigned long)NUM2INT(argv[3]);
981
958
  case 3:
982
- #if defined(HAVE_TYPE_DITHERMETHOD) && defined(HAVE_ENUM_NODITHERMETHOD)
983
959
  if (rb_obj_is_kind_of(argv[2], Class_DitherMethod))
984
960
  {
985
961
  VALUE_TO_ENUM(argv[2], quantize_info.dither_method, DitherMethod);
986
962
  quantize_info.dither = quantize_info.dither_method != NoDitherMethod;
987
963
  }
988
- #else
989
- quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
990
- #endif
964
+ else
965
+ {
966
+ quantize_info.dither = (MagickBooleanType) RTEST(argv[2]);
967
+ }
991
968
  case 2:
992
969
  VALUE_TO_ENUM(argv[1], quantize_info.colorspace, ColorspaceType);
993
970
  case 1:
@@ -1001,8 +978,8 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
1001
978
 
1002
979
 
1003
980
  // Convert image array to image sequence, clone image sequence.
1004
- exception = AcquireExceptionInfo();
1005
981
  images = images_from_imagelist(self);
982
+ exception = AcquireExceptionInfo();
1006
983
  new_images = CloneImageList(images, exception);
1007
984
  rm_split(images);
1008
985
  rm_check_exception(exception, new_images, DestroyOnError);
@@ -1054,7 +1031,6 @@ ImageList_quantize(int argc, VALUE *argv, VALUE self)
1054
1031
  VALUE
1055
1032
  ImageList_remap(int argc, VALUE *argv, VALUE self)
1056
1033
  {
1057
- #if defined(HAVE_REMAPIMAGES) || defined(HAVE_AFFINITYIMAGES)
1058
1034
  Image *images, *remap_image = NULL;
1059
1035
  QuantizeInfo quantize_info;
1060
1036
 
@@ -1080,22 +1056,11 @@ ImageList_remap(int argc, VALUE *argv, VALUE self)
1080
1056
 
1081
1057
  images = images_from_imagelist(self);
1082
1058
 
1083
- #if defined(HAVE_REMAPIMAGE)
1084
1059
  (void) RemapImages(&quantize_info, images, remap_image);
1085
- #else
1086
- (void) AffinityImages(&quantize_info, images, remap_image);
1087
- #endif
1088
1060
  rm_check_image_exception(images, RetainOnError);
1089
1061
  rm_split(images);
1090
1062
 
1091
1063
  return self;
1092
- #else
1093
- self = self;
1094
- argc = argc;
1095
- argv = argv;
1096
- rm_not_implemented();
1097
- return(VALUE)0;
1098
- #endif
1099
1064
  }
1100
1065
 
1101
1066
 
@@ -1207,7 +1172,7 @@ ImageList_write(VALUE self, VALUE file)
1207
1172
 
1208
1173
  if (TYPE(file) == T_FILE)
1209
1174
  {
1210
- OpenFile *fptr;
1175
+ rb_io_t *fptr;
1211
1176
 
1212
1177
  // Ensure file is open - raise error if not
1213
1178
  GetOpenFile(file, fptr);
@@ -1215,7 +1180,7 @@ ImageList_write(VALUE self, VALUE file)
1215
1180
  add_format_prefix(info, fptr->pathv);
1216
1181
  SetImageInfoFile(info, NULL);
1217
1182
  #else
1218
- SetImageInfoFile(info, GetReadFile(fptr));
1183
+ SetImageInfoFile(info, rb_io_stdio_file(fptr));
1219
1184
  #endif
1220
1185
  }
1221
1186
  else
@@ -1245,7 +1210,7 @@ ImageList_write(VALUE self, VALUE file)
1245
1210
  (void) DestroyExceptionInfo(exception);
1246
1211
 
1247
1212
  // Tell WriteImage if we want a multi-images file.
1248
- if (imagelist_length(self) > 1L && m->adjoin)
1213
+ if (imagelist_length(self) > 1L && GetMagickAdjoin(m))
1249
1214
  {
1250
1215
  info->adjoin = MagickTrue;
1251
1216
  }