rmagick 3.1.0 → 3.2.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 (80) hide show
  1. checksums.yaml +4 -4
  2. data/.appveyor.yml +4 -4
  3. data/.circleci/config.yml +1 -1
  4. data/.gitignore +1 -0
  5. data/.rubocop_todo.yml +6 -0
  6. data/.travis.yml +26 -8
  7. data/CHANGELOG.md +104 -0
  8. data/before_install_linux.sh +19 -10
  9. data/benchmarks/memory/README.md +50 -0
  10. data/benchmarks/memory/image_new.rb +8 -0
  11. data/benchmarks/memory/rmagick.gnuplot +16 -0
  12. data/doc/ex/coalesce.rb +2 -2
  13. data/doc/ex/drawcomp.rb +3 -3
  14. data/doc/ex/get_pixels.rb +1 -1
  15. data/doc/ex/images/Coffee.png +0 -0
  16. data/doc/ex/images/No.png +0 -0
  17. data/doc/ex/images/Snake.png +0 -0
  18. data/doc/ex/implode.rb +2 -2
  19. data/doc/ex/mask.rb +1 -1
  20. data/doc/ex/matte_fill_to_border.rb +1 -1
  21. data/doc/ex/matte_floodfill.rb +1 -1
  22. data/doc/ex/matte_replace.rb +1 -1
  23. data/doc/ex/stegano.rb +1 -1
  24. data/examples/constitute.rb +1 -1
  25. data/examples/crop_with_gravity.rb +1 -1
  26. data/examples/demo.rb +4 -4
  27. data/examples/find_similar_region.rb +1 -1
  28. data/examples/histogram.rb +3 -3
  29. data/examples/identify.rb +46 -46
  30. data/examples/image_opacity.rb +2 -2
  31. data/examples/vignette.rb +3 -3
  32. data/ext/RMagick/extconf.rb +19 -15
  33. data/ext/RMagick/rmagick.c +1 -2
  34. data/ext/RMagick/rmagick.h +59 -30
  35. data/ext/RMagick/rmdraw.c +62 -274
  36. data/ext/RMagick/rmenum.c +121 -665
  37. data/ext/RMagick/rmfill.c +7 -7
  38. data/ext/RMagick/rmilist.c +91 -7
  39. data/ext/RMagick/rmimage.c +568 -379
  40. data/ext/RMagick/rminfo.c +152 -110
  41. data/ext/RMagick/rmkinfo.c +17 -1
  42. data/ext/RMagick/rmmain.c +75 -74
  43. data/ext/RMagick/rmmontage.c +33 -33
  44. data/ext/RMagick/rmpixel.c +75 -14
  45. data/ext/RMagick/rmstruct.c +5 -5
  46. data/ext/RMagick/rmutil.c +3 -13
  47. data/lib/obsolete.rb +66 -0
  48. data/lib/rmagick/version.rb +1 -1
  49. data/lib/rmagick_internal.rb +54 -41
  50. data/spec/rmagick/image/composite_spec.rb +5 -76
  51. data/spec/rmagick/image/properties_spec.rb +1 -1
  52. data/test/Draw.rb +52 -115
  53. data/test/Enum.rb +153 -1
  54. data/test/Fill.rb +1 -1
  55. data/test/Image1.rb +97 -43
  56. data/test/Image2.rb +140 -36
  57. data/test/Image3.rb +110 -120
  58. data/test/ImageList1.rb +46 -11
  59. data/test/ImageList2.rb +11 -21
  60. data/test/Image_attributes.rb +81 -127
  61. data/test/Import_Export.rb +2 -2
  62. data/test/Info.rb +5 -1
  63. data/test/KernelInfo.rb +67 -0
  64. data/test/Magick.rb +17 -35
  65. data/test/Pixel.rb +193 -24
  66. data/test/PolaroidOptions.rb +1 -1
  67. data/test/Preview.rb +3 -35
  68. data/test/Struct.rb +45 -0
  69. data/test/appearance/Montage.rb +26 -0
  70. data/test/appearance/appearance_assertion.rb +13 -0
  71. data/test/appearance/expected/montage_border_color.jpg +0 -0
  72. data/test/lib/Obsolete.rb +30 -0
  73. data/test/lib/internal/Draw.rb +823 -0
  74. data/test/lib/internal/Geometry.rb +98 -0
  75. data/test/lib/internal/Magick.rb +40 -0
  76. data/test/test_all_basic.rb +16 -17
  77. metadata +27 -5
  78. data/doc/ex/images/Coffee.wmf +0 -0
  79. data/doc/ex/images/No.wmf +0 -0
  80. data/doc/ex/images/Snake.wmf +0 -0
@@ -71,7 +71,7 @@ get_option(VALUE self, const char *key)
71
71
  * @param self this object
72
72
  * @param key the option key
73
73
  * @param string the value
74
- * @return self
74
+ * @return string
75
75
  */
76
76
  static VALUE
77
77
  set_option(VALUE self, const char *key, VALUE string)
@@ -90,7 +90,7 @@ set_option(VALUE self, const char *key, VALUE string)
90
90
  value = StringValuePtr(string);
91
91
  (void) SetImageOption(info, key, value);
92
92
  }
93
- return self;
93
+ return string;
94
94
  }
95
95
 
96
96
 
@@ -105,7 +105,7 @@ set_option(VALUE self, const char *key, VALUE string)
105
105
  * @param self this object
106
106
  * @param option the option
107
107
  * @param color the color name
108
- * @return self
108
+ * @return color
109
109
  */
110
110
  static VALUE set_color_option(VALUE self, const char *option, VALUE color)
111
111
  {
@@ -135,7 +135,7 @@ static VALUE set_color_option(VALUE self, const char *option, VALUE color)
135
135
  (void) SetImageOption(info, option, name);
136
136
  }
137
137
 
138
- return self;
138
+ return color;
139
139
  }
140
140
 
141
141
 
@@ -183,7 +183,7 @@ static VALUE get_dbl_option(VALUE self, const char *option)
183
183
  * @param self this object
184
184
  * @param option the option name
185
185
  * @param value the value
186
- * @return self
186
+ * @return value
187
187
  */
188
188
  static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
189
189
  {
@@ -215,7 +215,7 @@ static VALUE set_dbl_option(VALUE self, const char *option, VALUE value)
215
215
  (void) SetImageOption(info, option, buff);
216
216
  }
217
217
 
218
- return self;
218
+ return value;
219
219
  }
220
220
 
221
221
 
@@ -283,7 +283,7 @@ Info_aref(int argc, VALUE *argv, VALUE self)
283
283
  rb_raise(rb_eArgError, "can't reference %.60s:%.1024s - too long", format_p, key_p);
284
284
  }
285
285
 
286
- sprintf(fkey, "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
286
+ snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
287
287
  break;
288
288
 
289
289
  case 1:
@@ -354,7 +354,7 @@ Info_aset(int argc, VALUE *argv, VALUE self)
354
354
  rb_raise(rb_eArgError, "%.60s:%.1024s not defined - too long", format_p, key_p);
355
355
  }
356
356
 
357
- (void) sprintf(ckey, "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);
357
+ (void) snprintf(ckey, sizeof(ckey), "%.60s:%.*s", format_p, (int)(sizeof(ckey)-MAX_FORMAT_LEN), key_p);
358
358
 
359
359
  value = argv[2];
360
360
  break;
@@ -443,14 +443,7 @@ Info_authenticate(VALUE self)
443
443
  Info *info;
444
444
 
445
445
  Data_Get_Struct(self, Info, info);
446
- if (info->authenticate)
447
- {
448
- return rb_str_new2(info->authenticate);
449
- }
450
- else
451
- {
452
- return Qnil;
453
- }
446
+ return C_str_to_R_str(info->authenticate);
454
447
  }
455
448
 
456
449
 
@@ -461,21 +454,20 @@ Info_authenticate(VALUE self)
461
454
  * - @verbatim Info#authenticate= @endverbatim
462
455
  *
463
456
  * @param self this object
464
- * @param passwd the authenticating password
465
- * @return self
457
+ * @param passwd_arg the authenticating password
458
+ * @return passwd_arg
466
459
  */
467
460
  VALUE
468
- Info_authenticate_eq(VALUE self, VALUE passwd)
461
+ Info_authenticate_eq(VALUE self, VALUE passwd_arg)
469
462
  {
470
463
  Info *info;
471
- char *passwd_p = NULL;
472
- long passwd_l = 0;
464
+ char *passwd = NULL;
473
465
 
474
466
  Data_Get_Struct(self, Info, info);
475
467
 
476
- if (!NIL_P(passwd))
468
+ if (!NIL_P(passwd_arg))
477
469
  {
478
- passwd_p = rm_str2cstr(passwd, &passwd_l);
470
+ passwd = StringValuePtr(passwd_arg);
479
471
  }
480
472
 
481
473
  if (info->authenticate)
@@ -483,12 +475,12 @@ Info_authenticate_eq(VALUE self, VALUE passwd)
483
475
  magick_free(info->authenticate);
484
476
  info->authenticate = NULL;
485
477
  }
486
- if (passwd_l > 0)
478
+ if (passwd)
487
479
  {
488
- magick_clone_string(&info->authenticate, passwd_p);
480
+ magick_clone_string(&info->authenticate, passwd);
489
481
  }
490
482
 
491
- return self;
483
+ return passwd_arg;
492
484
  }
493
485
 
494
486
 
@@ -523,7 +515,7 @@ Info_background_color(VALUE self)
523
515
  *
524
516
  * @param self this object
525
517
  * @param bc_arg the background color
526
- * @return self
518
+ * @return bc_arg
527
519
  * @throw ArgumentError
528
520
  */
529
521
  VALUE
@@ -535,7 +527,7 @@ Info_background_color_eq(VALUE self, VALUE bc_arg)
535
527
  Data_Get_Struct(self, Info, info);
536
528
  Color_to_PixelColor(&info->background_color, bc_arg);
537
529
  //SetImageOption(info, "background", pixel_packet_to_hexname(&info->background_color, colorname));
538
- return self;
530
+ return bc_arg;
539
531
  }
540
532
 
541
533
  /**
@@ -568,7 +560,7 @@ Info_border_color(VALUE self)
568
560
  *
569
561
  * @param self this object
570
562
  * @param bc_arg the border color
571
- * @return self
563
+ * @return bc_arg
572
564
  * @throw ArgumentError
573
565
  */
574
566
  VALUE
@@ -580,7 +572,7 @@ Info_border_color_eq(VALUE self, VALUE bc_arg)
580
572
  Data_Get_Struct(self, Info, info);
581
573
  Color_to_PixelColor(&info->border_color, bc_arg);
582
574
  //SetImageOption(info, "bordercolor", pixel_packet_to_hexname(&info->border_color, colorname));
583
- return self;
575
+ return bc_arg;
584
576
  }
585
577
 
586
578
 
@@ -672,7 +664,7 @@ Info_colorspace(VALUE self)
672
664
  Info *info;
673
665
 
674
666
  Data_Get_Struct(self, Info, info);
675
- return ColorspaceType_new(info->colorspace);
667
+ return ColorspaceType_find(info->colorspace);
676
668
  }
677
669
 
678
670
  /**
@@ -683,7 +675,7 @@ Info_colorspace(VALUE self)
683
675
  *
684
676
  * @param self this object
685
677
  * @param colorspace the colorspace type
686
- * @return self
678
+ * @return colorspace
687
679
  * @throw ArgumentError
688
680
  */
689
681
  VALUE
@@ -693,7 +685,7 @@ Info_colorspace_eq(VALUE self, VALUE colorspace)
693
685
 
694
686
  Data_Get_Struct(self, Info, info);
695
687
  VALUE_TO_ENUM(colorspace, info->colorspace, ColorspaceType);
696
- return self;
688
+ return colorspace;
697
689
  }
698
690
 
699
691
  OPTION_ATTR_ACCESSOR(comment, Comment)
@@ -713,7 +705,7 @@ Info_compression(VALUE self)
713
705
  Info *info;
714
706
 
715
707
  Data_Get_Struct(self, Info, info);
716
- return CompressionType_new(info->compression);
708
+ return CompressionType_find(info->compression);
717
709
  }
718
710
 
719
711
  /**
@@ -724,7 +716,7 @@ Info_compression(VALUE self)
724
716
  *
725
717
  * @param self this object
726
718
  * @param type the compression type
727
- * @return self
719
+ * @return type
728
720
  * @throw ArgumentError
729
721
  */
730
722
  VALUE
@@ -734,7 +726,7 @@ Info_compression_eq(VALUE self, VALUE type)
734
726
 
735
727
  Data_Get_Struct(self, Info, info);
736
728
  VALUE_TO_ENUM(type, info->compression, CompressionType);
737
- return self;
729
+ return type;
738
730
  }
739
731
 
740
732
  /**
@@ -845,9 +837,7 @@ Info_delay(VALUE self)
845
837
  static VALUE
846
838
  arg_is_integer(VALUE arg)
847
839
  {
848
- int d = NUM2INT(arg);
849
- d = d; // satisfy icc
850
- return arg;
840
+ return INT2NUM(NUM2INT(arg));
851
841
  }
852
842
 
853
843
  /**
@@ -861,7 +851,7 @@ arg_is_integer(VALUE arg)
861
851
  *
862
852
  * @param self this object
863
853
  * @param string the delay
864
- * @return self
854
+ * @return string
865
855
  */
866
856
  VALUE
867
857
  Info_delay_eq(VALUE self, VALUE string)
@@ -889,7 +879,7 @@ Info_delay_eq(VALUE self, VALUE string)
889
879
  sprintf(dstr, "%d", delay);
890
880
  (void) SetImageOption(info, "delay", dstr);
891
881
  }
892
- return self;
882
+ return string;
893
883
  }
894
884
 
895
885
  /**
@@ -914,7 +904,7 @@ DEF_ATTR_READER(Info, density, str)
914
904
  *
915
905
  * @param self this object
916
906
  * @param density_arg the density
917
- * @return self
907
+ * @return density_arg
918
908
  * @throw ArgumentError
919
909
  */
920
910
  VALUE
@@ -944,7 +934,7 @@ Info_density_eq(VALUE self, VALUE density_arg)
944
934
 
945
935
  RB_GC_GUARD(density);
946
936
 
947
- return self;
937
+ return density_arg;
948
938
  }
949
939
 
950
940
  /**
@@ -966,7 +956,7 @@ DEF_ATTR_READER(Info, depth, int)
966
956
  *
967
957
  * @param self this object
968
958
  * @param depth the depth
969
- * @return self
959
+ * @return depth
970
960
  * @throw ArgumentError
971
961
  */
972
962
  VALUE
@@ -996,7 +986,7 @@ Info_depth_eq(VALUE self, VALUE depth)
996
986
  }
997
987
 
998
988
  info->depth = d;
999
- return self;
989
+ return depth;
1000
990
  }
1001
991
 
1002
992
  /** A dispose option */
@@ -1093,7 +1083,7 @@ Info_dispose(VALUE self)
1093
1083
  *
1094
1084
  * @param self this object
1095
1085
  * @param disp the DisposeType enumerator
1096
- * @return self
1086
+ * @return disp
1097
1087
  */
1098
1088
  VALUE
1099
1089
  Info_dispose_eq(VALUE self, VALUE disp)
@@ -1124,7 +1114,7 @@ Info_dispose_eq(VALUE self, VALUE disp)
1124
1114
  }
1125
1115
 
1126
1116
  (void) SetImageOption(info, "dispose", option);
1127
- return self;
1117
+ return disp;
1128
1118
  }
1129
1119
 
1130
1120
  DEF_ATTR_ACCESSOR(Info, dither, bool)
@@ -1145,7 +1135,7 @@ Info_endian(VALUE self)
1145
1135
  Info *info;
1146
1136
 
1147
1137
  Data_Get_Struct(self, Info, info);
1148
- return EndianType_new(info->endian);
1138
+ return EndianType_find(info->endian);
1149
1139
  }
1150
1140
 
1151
1141
 
@@ -1157,7 +1147,7 @@ Info_endian(VALUE self)
1157
1147
  *
1158
1148
  * @param self this object
1159
1149
  * @param endian the endian (Magick::MSBEndian or Magick::LSBEndian)
1160
- * @return self
1150
+ * @return endian
1161
1151
  */
1162
1152
  VALUE
1163
1153
  Info_endian_eq(VALUE self, VALUE endian)
@@ -1172,7 +1162,7 @@ Info_endian_eq(VALUE self, VALUE endian)
1172
1162
 
1173
1163
  Data_Get_Struct(self, Info, info);
1174
1164
  info->endian = type;
1175
- return self;
1165
+ return endian;
1176
1166
  }
1177
1167
 
1178
1168
 
@@ -1201,7 +1191,7 @@ DEF_ATTR_READER(Info, extract, str)
1201
1191
  *
1202
1192
  * @param self this object
1203
1193
  * @param extract_arg the extract string
1204
- * @return self
1194
+ * @return extract_arg
1205
1195
  * @throw ArgumentError
1206
1196
  */
1207
1197
  VALUE
@@ -1231,7 +1221,7 @@ Info_extract_eq(VALUE self, VALUE extract_arg)
1231
1221
 
1232
1222
  RB_GC_GUARD(extract);
1233
1223
 
1234
- return self;
1224
+ return extract_arg;
1235
1225
  }
1236
1226
 
1237
1227
 
@@ -1268,7 +1258,7 @@ Info_filename(VALUE self)
1268
1258
  *
1269
1259
  * @param self this object
1270
1260
  * @param filename the filename
1271
- * @return self
1261
+ * @return filename
1272
1262
  * @see Image_capture
1273
1263
  */
1274
1264
  VALUE
@@ -1290,7 +1280,7 @@ Info_filename_eq(VALUE self, VALUE filename)
1290
1280
  fname = StringValuePtr(filename);
1291
1281
  strncpy(info->filename, fname, MaxTextExtent);
1292
1282
  }
1293
- return self;
1283
+ return filename;
1294
1284
  }
1295
1285
 
1296
1286
 
@@ -1346,7 +1336,7 @@ DEF_ATTR_READER(Info, font, str)
1346
1336
  *
1347
1337
  * @param self this object
1348
1338
  * @param font_arg the font (as a String)
1349
- * @return self
1339
+ * @return font_arg
1350
1340
  */
1351
1341
  VALUE
1352
1342
  Info_font_eq(VALUE self, VALUE font_arg)
@@ -1365,7 +1355,7 @@ Info_font_eq(VALUE self, VALUE font_arg)
1365
1355
  font = StringValuePtr(font_arg);
1366
1356
  magick_clone_string(&info->font, font);
1367
1357
  }
1368
- return self;
1358
+ return font_arg;
1369
1359
  }
1370
1360
 
1371
1361
  /**
@@ -1404,7 +1394,7 @@ VALUE Info_format(VALUE self)
1404
1394
  *
1405
1395
  * @param self this object
1406
1396
  * @param magick the encoding format
1407
- * @return self
1397
+ * @return magick
1408
1398
  */
1409
1399
  VALUE
1410
1400
  Info_format_eq(VALUE self, VALUE magick)
@@ -1429,7 +1419,7 @@ Info_format_eq(VALUE self, VALUE magick)
1429
1419
  }
1430
1420
 
1431
1421
  strncpy(info->magick, m->name, MaxTextExtent-1);
1432
- return self;
1422
+ return magick;
1433
1423
  }
1434
1424
 
1435
1425
  /**
@@ -1453,7 +1443,7 @@ DEF_ATTR_READER(Info, fuzz, dbl)
1453
1443
  *
1454
1444
  * @param self this object
1455
1445
  * @param fuzz the fuzz
1456
- * @return self
1446
+ * @return fuzz
1457
1447
  * @see Image_fuzz_eq
1458
1448
  */
1459
1449
  VALUE Info_fuzz_eq(VALUE self, VALUE fuzz)
@@ -1462,7 +1452,7 @@ VALUE Info_fuzz_eq(VALUE self, VALUE fuzz)
1462
1452
 
1463
1453
  Data_Get_Struct(self, Info, info);
1464
1454
  info->fuzz = rm_fuzz_to_dbl(fuzz);
1465
- return self;
1455
+ return fuzz;
1466
1456
  }
1467
1457
 
1468
1458
  /** A gravity option */
@@ -1563,7 +1553,7 @@ VALUE Info_gravity(VALUE self)
1563
1553
  *
1564
1554
  * @param self this object
1565
1555
  * @param grav the gravity enumerator
1566
- * @return self
1556
+ * @return grav
1567
1557
  */
1568
1558
  VALUE
1569
1559
  Info_gravity_eq(VALUE self, VALUE grav)
@@ -1594,11 +1584,56 @@ Info_gravity_eq(VALUE self, VALUE grav)
1594
1584
  }
1595
1585
 
1596
1586
  (void) SetImageOption(info, "gravity", option);
1597
- return self;
1587
+ return grav;
1588
+ }
1589
+
1590
+
1591
+ /**
1592
+ * Get the group attribute.
1593
+ *
1594
+ * Ruby usage:
1595
+ * - @verbatim Info#group @endverbatim
1596
+ *
1597
+ * @param self this object
1598
+ * @return the group
1599
+ * @deprecated This method has been deprecated.
1600
+ */
1601
+ VALUE
1602
+ Info_group(VALUE self)
1603
+ {
1604
+ Info *info;
1605
+
1606
+ rb_warning("Info#group is deprecated");
1607
+ (void) rm_check_destroyed(self);
1608
+ Data_Get_Struct(self, Info, info);
1609
+ return C_long_to_R_long(info->group);
1598
1610
  }
1599
1611
 
1600
1612
 
1601
- DEF_ATTR_ACCESSOR(Info, group, long)
1613
+ /**
1614
+ * Set the group attribute.
1615
+ *
1616
+ * Ruby usage:
1617
+ * - @verbatim Info#group= @endverbatim
1618
+ *
1619
+ * @param self this object
1620
+ * @param value the group
1621
+ * @return value
1622
+ * @deprecated This method has been deprecated.
1623
+ */
1624
+ VALUE
1625
+ Info_group_eq(VALUE self, VALUE value)
1626
+ {
1627
+ Info *info;
1628
+
1629
+ rb_warning("Info#group= is deprecated");
1630
+ (void) rm_check_destroyed(self);
1631
+ rb_check_frozen(self);
1632
+ Data_Get_Struct(self, Info, info);
1633
+ info->group = R_long_to_C_long(value);
1634
+ return value;
1635
+ }
1636
+
1602
1637
 
1603
1638
  /**
1604
1639
  * Get the classification type.
@@ -1615,7 +1650,7 @@ Info_image_type(VALUE self)
1615
1650
  Info *info;
1616
1651
 
1617
1652
  Data_Get_Struct(self, Info, info);
1618
- return ImageType_new(info->type);
1653
+ return ImageType_find(info->type);
1619
1654
  }
1620
1655
 
1621
1656
  /**
@@ -1626,7 +1661,7 @@ Info_image_type(VALUE self)
1626
1661
  *
1627
1662
  * @param self this object
1628
1663
  * @param type the classification type
1629
- * @return self
1664
+ * @return type
1630
1665
  * @throw ArgumentError
1631
1666
  */
1632
1667
  VALUE
@@ -1636,7 +1671,7 @@ Info_image_type_eq(VALUE self, VALUE type)
1636
1671
 
1637
1672
  Data_Get_Struct(self, Info, info);
1638
1673
  VALUE_TO_ENUM(type, info->type, ImageType);
1639
- return self;
1674
+ return type;
1640
1675
  }
1641
1676
 
1642
1677
  /**
@@ -1654,7 +1689,7 @@ Info_interlace(VALUE self)
1654
1689
  Info *info;
1655
1690
 
1656
1691
  Data_Get_Struct(self, Info, info);
1657
- return InterlaceType_new(info->interlace);
1692
+ return InterlaceType_find(info->interlace);
1658
1693
  }
1659
1694
 
1660
1695
  /**
@@ -1665,7 +1700,7 @@ Info_interlace(VALUE self)
1665
1700
  *
1666
1701
  * @param self this object
1667
1702
  * @param inter the interlace type
1668
- * @return self
1703
+ * @return inter
1669
1704
  * @throw ArgumentError
1670
1705
  */
1671
1706
  VALUE
@@ -1675,7 +1710,7 @@ Info_interlace_eq(VALUE self, VALUE inter)
1675
1710
 
1676
1711
  Data_Get_Struct(self, Info, info);
1677
1712
  VALUE_TO_ENUM(inter, info->interlace, InterlaceType);
1678
- return self;
1713
+ return inter;
1679
1714
  }
1680
1715
 
1681
1716
  OPTION_ATTR_ACCESSOR(label, Label)
@@ -1707,7 +1742,7 @@ Info_matte_color(VALUE self)
1707
1742
  *
1708
1743
  * @param self this object
1709
1744
  * @param matte_arg the name of the matte as a String
1710
- * @return self
1745
+ * @return matte_arg
1711
1746
  * @throw ArgumentError
1712
1747
  */
1713
1748
  VALUE
@@ -1719,7 +1754,7 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
1719
1754
  Data_Get_Struct(self, Info, info);
1720
1755
  Color_to_PixelColor(&info->matte_color, matte_arg);
1721
1756
  //SetImageOption(info, "mattecolor", pixel_packet_to_hexname(&info->matte_color, colorname));
1722
- return self;
1757
+ return matte_arg;
1723
1758
  }
1724
1759
 
1725
1760
  /**
@@ -1730,7 +1765,7 @@ Info_matte_color_eq(VALUE self, VALUE matte_arg)
1730
1765
  *
1731
1766
  * @param self this object
1732
1767
  * @param monitor the monitor
1733
- * @return self
1768
+ * @return monitor
1734
1769
  * @see Image_monitor_eq
1735
1770
  */
1736
1771
  VALUE
@@ -1749,7 +1784,7 @@ Info_monitor_eq(VALUE self, VALUE monitor)
1749
1784
  (void) SetImageInfoProgressMonitor(info, rm_progress_monitor, (void *)monitor);
1750
1785
  }
1751
1786
 
1752
- return self;
1787
+ return monitor;
1753
1788
  }
1754
1789
 
1755
1790
 
@@ -1774,7 +1809,7 @@ Info_orientation(VALUE self)
1774
1809
  Info *info;
1775
1810
 
1776
1811
  Data_Get_Struct(self, Info, info);
1777
- return OrientationType_new(info->orientation);
1812
+ return OrientationType_find(info->orientation);
1778
1813
  }
1779
1814
 
1780
1815
 
@@ -1786,7 +1821,7 @@ Info_orientation(VALUE self)
1786
1821
  *
1787
1822
  * @param self this object
1788
1823
  * @param inter the orientation type as an OrientationType enum value
1789
- * @return self
1824
+ * @return inter
1790
1825
  * @throw ArgumentError
1791
1826
  */
1792
1827
  VALUE
@@ -1796,7 +1831,7 @@ Info_orientation_eq(VALUE self, VALUE inter)
1796
1831
 
1797
1832
  Data_Get_Struct(self, Info, info);
1798
1833
  VALUE_TO_ENUM(inter, info->orientation, OrientationType);
1799
- return self;
1834
+ return inter;
1800
1835
  }
1801
1836
 
1802
1837
 
@@ -1831,7 +1866,7 @@ Info_origin(VALUE self)
1831
1866
  *
1832
1867
  * @param self this object
1833
1868
  * @param origin_arg the origin geometry
1834
- * @return self
1869
+ * @return origin_arg
1835
1870
  */
1836
1871
  VALUE
1837
1872
  Info_origin_eq(VALUE self, VALUE origin_arg)
@@ -1862,7 +1897,7 @@ Info_origin_eq(VALUE self, VALUE origin_arg)
1862
1897
 
1863
1898
  RB_GC_GUARD(origin_str);
1864
1899
 
1865
- return self;
1900
+ return origin_arg;
1866
1901
  }
1867
1902
 
1868
1903
 
@@ -1894,7 +1929,7 @@ Info_page(VALUE self)
1894
1929
  *
1895
1930
  * @param self this object
1896
1931
  * @param page_arg the geometry
1897
- * @return self
1932
+ * @return page_arg
1898
1933
  */
1899
1934
  VALUE
1900
1935
  Info_page_eq(VALUE self, VALUE page_arg)
@@ -1922,7 +1957,7 @@ Info_page_eq(VALUE self, VALUE page_arg)
1922
1957
 
1923
1958
  RB_GC_GUARD(geom_str);
1924
1959
 
1925
- return self;
1960
+ return page_arg;
1926
1961
  }
1927
1962
 
1928
1963
  DEF_ATTR_ACCESSOR(Info, pointsize, dbl)
@@ -1961,7 +1996,7 @@ Info_sampling_factor(VALUE self)
1961
1996
  *
1962
1997
  * @param self this object
1963
1998
  * @param sampling_factor the sampling factors
1964
- * @return self
1999
+ * @return sampling_factor
1965
2000
  */
1966
2001
  VALUE
1967
2002
  Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
@@ -1987,7 +2022,7 @@ Info_sampling_factor_eq(VALUE self, VALUE sampling_factor)
1987
2022
  magick_clone_string(&info->sampling_factor, sampling_factor_p);
1988
2023
  }
1989
2024
 
1990
- return self;
2025
+ return sampling_factor;
1991
2026
  }
1992
2027
 
1993
2028
 
@@ -2018,7 +2053,7 @@ Info_scene(VALUE self)
2018
2053
  *
2019
2054
  * @param self this object
2020
2055
  * @param scene the scene number
2021
- * @return self
2056
+ * @return scene
2022
2057
  */
2023
2058
  VALUE
2024
2059
  Info_scene_eq(VALUE self, VALUE scene)
@@ -2029,14 +2064,10 @@ Info_scene_eq(VALUE self, VALUE scene)
2029
2064
  Data_Get_Struct(self, Info, info);
2030
2065
  info->scene = NUM2ULONG(scene);
2031
2066
 
2032
- #if defined(HAVE_SNPRINTF)
2033
2067
  (void) snprintf(buf, sizeof(buf), "%-ld", info->scene);
2034
- #else
2035
- (void) sprintf(buf, "%-l", info->scene);
2036
- #endif
2037
2068
  (void) SetImageOption(info, "scene", buf);
2038
2069
 
2039
- return self;
2070
+ return scene;
2040
2071
  }
2041
2072
 
2042
2073
 
@@ -2060,7 +2091,7 @@ DEF_ATTR_READER(Info, server_name, str)
2060
2091
  *
2061
2092
  * @param self this object
2062
2093
  * @param server_arg the server name as a String
2063
- * @return self
2094
+ * @return server_arg
2064
2095
  */
2065
2096
  VALUE
2066
2097
  Info_server_name_eq(VALUE self, VALUE server_arg)
@@ -2079,7 +2110,7 @@ Info_server_name_eq(VALUE self, VALUE server_arg)
2079
2110
  server = StringValuePtr(server_arg);
2080
2111
  magick_clone_string(&info->server_name, server);
2081
2112
  }
2082
- return self;
2113
+ return server_arg;
2083
2114
  }
2084
2115
 
2085
2116
  /**
@@ -2102,7 +2133,7 @@ DEF_ATTR_READER(Info, size, str)
2102
2133
  *
2103
2134
  * @param self this object
2104
2135
  * @param size_arg the size
2105
- * @return self
2136
+ * @return size_arg
2106
2137
  * @throw ArgumentError
2107
2138
  */
2108
2139
  VALUE
@@ -2132,7 +2163,7 @@ Info_size_eq(VALUE self, VALUE size_arg)
2132
2163
 
2133
2164
  RB_GC_GUARD(size);
2134
2165
 
2135
- return self;
2166
+ return size_arg;
2136
2167
  }
2137
2168
 
2138
2169
 
@@ -2216,7 +2247,7 @@ Info_stroke_width_eq(VALUE self, VALUE stroke_width)
2216
2247
  *
2217
2248
  * @param self this object
2218
2249
  * @param texture the name of the texture image
2219
- * @return self
2250
+ * @return texture
2220
2251
  */
2221
2252
  VALUE
2222
2253
  Info_texture_eq(VALUE self, VALUE texture)
@@ -2238,7 +2269,7 @@ Info_texture_eq(VALUE self, VALUE texture)
2238
2269
  // If argument is nil we're done
2239
2270
  if (texture == Qnil)
2240
2271
  {
2241
- return self;
2272
+ return texture;
2242
2273
  }
2243
2274
 
2244
2275
  // Create a temp copy of the texture and store its name in the texture field
@@ -2247,7 +2278,7 @@ Info_texture_eq(VALUE self, VALUE texture)
2247
2278
 
2248
2279
  magick_clone_string(&info->texture, name);
2249
2280
 
2250
- return self;
2281
+ return texture;
2251
2282
  }
2252
2283
 
2253
2284
 
@@ -2259,7 +2290,7 @@ Info_texture_eq(VALUE self, VALUE texture)
2259
2290
  *
2260
2291
  * @param self this object
2261
2292
  * @param offset the offset
2262
- * @return self
2293
+ * @return offset
2263
2294
  */
2264
2295
  VALUE
2265
2296
  Info_tile_offset_eq(VALUE self, VALUE offset)
@@ -2282,7 +2313,7 @@ Info_tile_offset_eq(VALUE self, VALUE offset)
2282
2313
 
2283
2314
  RB_GC_GUARD(offset_str);
2284
2315
 
2285
- return self;
2316
+ return offset;
2286
2317
  }
2287
2318
 
2288
2319
 
@@ -2314,7 +2345,7 @@ Info_transparent_color(VALUE self)
2314
2345
  *
2315
2346
  * @param self this object
2316
2347
  * @param tc_arg the transparent color as a String
2317
- * @return self
2348
+ * @return tc_arg
2318
2349
  * @throw ArgumentError
2319
2350
  */
2320
2351
  VALUE
@@ -2326,7 +2357,7 @@ Info_transparent_color_eq(VALUE self, VALUE tc_arg)
2326
2357
  Data_Get_Struct(self, Info, info);
2327
2358
  Color_to_PixelColor(&info->transparent_color, tc_arg);
2328
2359
  //SetImageOption(info, "transparent", pixel_packet_to_hexname(&info->transparent_color, colorname));
2329
- return self;
2360
+ return tc_arg;
2330
2361
  }
2331
2362
 
2332
2363
 
@@ -2385,7 +2416,7 @@ Info_undefine(VALUE self, VALUE format, VALUE key)
2385
2416
  rb_raise(rb_eArgError, "can't undefine %.60s:%.1024s - too long", format_p, key_p);
2386
2417
  }
2387
2418
 
2388
- sprintf(fkey, "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
2419
+ snprintf(fkey, sizeof(fkey), "%.60s:%.*s", format_p, (int)(MaxTextExtent-61), key_p);
2389
2420
 
2390
2421
  Data_Get_Struct(self, Info, info);
2391
2422
  (void) DeleteImageOption(info, fkey);
@@ -2441,7 +2472,7 @@ Info_units(VALUE self)
2441
2472
  Info *info;
2442
2473
 
2443
2474
  Data_Get_Struct(self, Info, info);
2444
- return ResolutionType_new(info->units);
2475
+ return ResolutionType_find(info->units);
2445
2476
  }
2446
2477
 
2447
2478
  /**
@@ -2452,7 +2483,7 @@ Info_units(VALUE self)
2452
2483
  *
2453
2484
  * @param self this object
2454
2485
  * @param units the resolution type
2455
- * @return self
2486
+ * @return units
2456
2487
  * @throw ArgumentError
2457
2488
  */
2458
2489
  VALUE
@@ -2462,7 +2493,7 @@ Info_units_eq(VALUE self, VALUE units)
2462
2493
 
2463
2494
  Data_Get_Struct(self, Info, info);
2464
2495
  VALUE_TO_ENUM(units, info->units, ResolutionType);
2465
- return self;
2496
+ return units;
2466
2497
  }
2467
2498
 
2468
2499
  /**
@@ -2474,7 +2505,14 @@ Info_units_eq(VALUE self, VALUE units)
2474
2505
  * @param self this object.
2475
2506
  * @return the viewing parameters
2476
2507
  */
2477
- DEF_ATTR_READER(Info, view, str)
2508
+ VALUE
2509
+ Info_view(VALUE self)
2510
+ {
2511
+ Info *info;
2512
+
2513
+ Data_Get_Struct(self, Info, info);
2514
+ return C_str_to_R_str(info->view);
2515
+ }
2478
2516
 
2479
2517
  /**
2480
2518
  * Set FlashPix viewing parameters.
@@ -2484,27 +2522,31 @@ DEF_ATTR_READER(Info, view, str)
2484
2522
  *
2485
2523
  * @param self this object
2486
2524
  * @param view_arg the viewing parameters
2487
- * @return self
2525
+ * @return view_arg
2488
2526
  */
2489
2527
  VALUE
2490
2528
  Info_view_eq(VALUE self, VALUE view_arg)
2491
2529
  {
2492
2530
  Info *info;
2493
- char *view;
2531
+ char *view = NULL;
2494
2532
 
2495
2533
  Data_Get_Struct(self, Info, info);
2496
2534
 
2497
- if (NIL_P(view_arg) || StringValuePtr(view_arg) == NULL)
2535
+ if (!NIL_P(view_arg))
2536
+ {
2537
+ view = StringValuePtr(view_arg);
2538
+ }
2539
+
2540
+ if (info->view)
2498
2541
  {
2499
2542
  magick_free(info->view);
2500
2543
  info->view = NULL;
2501
2544
  }
2502
- else
2545
+ if (view)
2503
2546
  {
2504
- view = StringValuePtr(view_arg);
2505
2547
  magick_clone_string(&info->view, view);
2506
2548
  }
2507
- return self;
2549
+ return view_arg;
2508
2550
  }
2509
2551
 
2510
2552