ruby-vips 0.3.14 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (97) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +22 -0
  3. data/CHANGELOG.md +4 -0
  4. data/Gemfile +15 -0
  5. data/Gemfile.lock +46 -31
  6. data/{LICENSE → LICENSE.txt} +1 -1
  7. data/README.md +101 -145
  8. data/Rakefile +45 -0
  9. data/TODO +8 -32
  10. data/VERSION +1 -0
  11. data/example/annotate.rb +17 -0
  12. data/example/daltonize8.rb +75 -0
  13. data/example/example1.rb +84 -0
  14. data/example/example2.rb +31 -0
  15. data/example/example3.rb +19 -0
  16. data/example/example4.rb +18 -0
  17. data/example/example5.rb +31 -0
  18. data/example/trim8.rb +41 -0
  19. data/example/watermark.rb +44 -0
  20. data/example/wobble.rb +36 -0
  21. data/lib/vips.rb +151 -14
  22. data/lib/vips/access.rb +14 -0
  23. data/lib/vips/align.rb +11 -0
  24. data/lib/vips/angle.rb +12 -0
  25. data/lib/vips/angle45.rb +16 -0
  26. data/lib/vips/argument.rb +163 -0
  27. data/lib/vips/bandformat.rb +20 -0
  28. data/lib/vips/call.rb +302 -0
  29. data/lib/vips/coding.rb +14 -0
  30. data/lib/vips/demandstyle.rb +35 -0
  31. data/lib/vips/direction.rb +11 -0
  32. data/lib/vips/error.rb +30 -0
  33. data/lib/vips/extend.rb +22 -0
  34. data/lib/vips/foreignflags.rb +20 -0
  35. data/lib/vips/image.rb +1382 -0
  36. data/lib/vips/interpolate.rb +37 -0
  37. data/lib/vips/interpretation.rb +28 -0
  38. data/lib/vips/methods.rb +1807 -0
  39. data/lib/vips/operation.rb +19 -0
  40. data/ruby-vips8.gemspec +112 -0
  41. data/spec/image_spec.rb +515 -0
  42. data/spec/samples/balloon.v +0 -0
  43. data/spec/samples/ghost.ppm +405 -0
  44. data/spec/samples/huge.jpg +0 -0
  45. data/spec/samples/icc.jpg +0 -0
  46. data/spec/samples/lcd.icc +0 -0
  47. data/spec/samples/lion.svg +154 -0
  48. data/spec/samples/sample.csv +7 -0
  49. data/spec/samples/sample.exr +0 -0
  50. data/spec/samples/wagon.jpg +0 -0
  51. data/spec/samples/wagon.v +0 -0
  52. data/spec/spec_helper.rb +49 -0
  53. data/spec/vips_spec.rb +74 -0
  54. metadata +110 -70
  55. data/ext/extconf.rb +0 -31
  56. data/ext/header.c +0 -457
  57. data/ext/header.h +0 -9
  58. data/ext/image.c +0 -629
  59. data/ext/image.h +0 -72
  60. data/ext/image_arithmetic.c +0 -936
  61. data/ext/image_arithmetic.h +0 -38
  62. data/ext/image_boolean.c +0 -301
  63. data/ext/image_boolean.h +0 -8
  64. data/ext/image_colour.c +0 -590
  65. data/ext/image_colour.h +0 -36
  66. data/ext/image_conversion.c +0 -884
  67. data/ext/image_conversion.h +0 -38
  68. data/ext/image_convolution.c +0 -368
  69. data/ext/image_convolution.h +0 -13
  70. data/ext/image_freq_filt.c +0 -740
  71. data/ext/image_freq_filt.h +0 -27
  72. data/ext/image_histograms_lut.c +0 -643
  73. data/ext/image_histograms_lut.h +0 -28
  74. data/ext/image_morphology.c +0 -327
  75. data/ext/image_morphology.h +0 -13
  76. data/ext/image_mosaicing.c +0 -554
  77. data/ext/image_mosaicing.h +0 -15
  78. data/ext/image_relational.c +0 -384
  79. data/ext/image_relational.h +0 -8
  80. data/ext/image_resample.c +0 -249
  81. data/ext/image_resample.h +0 -9
  82. data/ext/interpolator.c +0 -106
  83. data/ext/interpolator.h +0 -7
  84. data/ext/mask.c +0 -347
  85. data/ext/mask.h +0 -18
  86. data/ext/reader.c +0 -261
  87. data/ext/reader.h +0 -2
  88. data/ext/ruby_vips.c +0 -188
  89. data/ext/ruby_vips.h +0 -72
  90. data/ext/tags +0 -450
  91. data/ext/writer.c +0 -371
  92. data/ext/writer.h +0 -2
  93. data/lib/vips/reader.rb +0 -272
  94. data/lib/vips/version.rb +0 -3
  95. data/lib/vips/writer.rb +0 -342
  96. data/ruby-vips.gemspec +0 -100
  97. data/ruby.supp +0 -134
@@ -1,9 +0,0 @@
1
- VALUE img_affinei(int, VALUE*, VALUE);
2
- VALUE img_affinei_resize(int, VALUE*, VALUE);
3
- VALUE img_stretch3(int, VALUE*, VALUE);
4
- VALUE img_shrink(int, VALUE*, VALUE);
5
- VALUE img_rightshift_size(VALUE, VALUE, VALUE, VALUE);
6
- VALUE img_match_linear(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE,
7
- VALUE, VALUE);
8
- VALUE img_match_linear_search(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE,
9
- VALUE, VALUE, VALUE, VALUE, VALUE);
@@ -1,106 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- static VALUE cVIPSInterpolator;
4
- static ID id_INTERPOLATORS;
5
-
6
- VipsInterpolate*
7
- interp_lookup(VALUE itrp_sym)
8
- {
9
- VALUE rb_interp;
10
- VipsInterpolate *itrp;
11
- VALUE hVIPSInterpolators = rb_const_get(cVIPSInterpolator,
12
- id_INTERPOLATORS);
13
-
14
- rb_interp = rb_hash_aref(hVIPSInterpolators, itrp_sym);
15
- Data_Get_Struct(rb_interp, VipsInterpolate, itrp);
16
-
17
- return itrp;
18
- }
19
-
20
- static void*
21
- interp_register(VipsInterpolateClass *itrp, void *hash)
22
- {
23
- VipsInterpolate *inst;
24
- VipsObjectClass *klass = (VipsObjectClass*) itrp;;
25
- VALUE obj, hVIPSInterpolators = (VALUE)hash;
26
-
27
- inst = vips_interpolate_new(klass->nickname);
28
- obj = Data_Wrap_Struct(cVIPSInterpolator, 0, 0, inst);
29
-
30
- rb_hash_aset(hVIPSInterpolators, ID2SYM(rb_intern(klass->nickname)), obj);
31
-
32
- return NULL;
33
- }
34
-
35
- static void
36
- interp_register_builtin()
37
- {
38
- VALUE hVIPSInterpolators = rb_hash_new();
39
-
40
- /* Hash of available interpolators. Keys are the symbols, and values are
41
- * interpolator objects.
42
- */
43
- rb_define_const(cVIPSInterpolator, "INTERPOLATORS", hVIPSInterpolators);
44
-
45
- vips_class_map_concrete_all(
46
- g_type_from_name( "VipsInterpolate" ),
47
- (void *) interp_register,
48
- (void *) hVIPSInterpolators
49
- );
50
- }
51
-
52
-
53
- /*
54
- * call-seq:
55
- * interp.nickname -> string
56
- *
57
- * Retrieve the internally used nickname of the interpolator.
58
- */
59
-
60
- static VALUE
61
- interp_nickname(VALUE obj)
62
- {
63
- VipsObject *v_obj;
64
- Data_Get_Struct(obj, VipsObject, v_obj);
65
- return rb_str_new2(v_obj->nickname);
66
- }
67
-
68
- /*
69
- * call-seq:
70
- * interp.description -> string
71
- *
72
- * Retrieve the description of the interpolator.
73
- */
74
-
75
- static VALUE
76
- interp_description(VALUE obj)
77
- {
78
- VipsObject *v_obj;
79
- Data_Get_Struct(obj, VipsObject, v_obj);
80
- return rb_str_new2(v_obj->description);
81
- }
82
-
83
- /*
84
- * VIPS Interpolators determine how color values will be estimated when an
85
- * image is modified.
86
- *
87
- * This class provides information on which interpolators are available to
88
- * VIPS.
89
- */
90
-
91
- void
92
- init_Interpolator(void)
93
- {
94
- cVIPSInterpolator = rb_define_class_under(mVIPS, "Interpolator", rb_cObject);
95
-
96
- rb_define_method(cVIPSInterpolator, "nickname", interp_nickname, 0);
97
- rb_define_method(cVIPSInterpolator, "description", interp_description, 0);
98
-
99
- id_INTERPOLATORS = rb_intern("INTERPOLATORS");
100
-
101
- interp_register_builtin();
102
-
103
- #if 0
104
- VALUE mVIPS = rb_define_module("VIPS");
105
- #endif
106
- }
@@ -1,7 +0,0 @@
1
- #ifndef RUBY_VIPS_INTERPOLATOR_H
2
- #define RUBY_VIPS_INTERPOLATOR_H
3
-
4
- VipsInterpolate* interp_lookup(VALUE);
5
- void init_Interpolator(void);
6
-
7
- #endif
data/ext/mask.c DELETED
@@ -1,347 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- VALUE cVIPSMask;
4
-
5
- static void
6
- mask_free(vipsMask *msk)
7
- {
8
- if(msk->dmask)
9
- im_free_dmask(msk->dmask);
10
-
11
- if(msk->imask)
12
- im_free_imask(msk->imask);
13
-
14
- xfree(msk);
15
- }
16
-
17
- VALUE
18
- mask_alloc(VALUE klass)
19
- {
20
- vipsMask *msk;
21
- VALUE new = Data_Make_Struct(klass, vipsMask, 0, mask_free, msk);
22
- msk->imask = NULL;
23
- msk->dmask = NULL;
24
-
25
- return new;
26
- }
27
-
28
- static int
29
- ary_is_int_2d(VALUE ary)
30
- {
31
- Check_Type(ary, T_ARRAY);
32
-
33
- VALUE *row, *rows = RARRAY_PTR(ary);
34
- int i, j;
35
- for(i = 0; i < RARRAY_LEN(ary); i++) {
36
- Check_Type(rows[i], T_ARRAY);
37
- for(j = 0; j < RARRAY_LEN(rows[i]); j++) {
38
- row = RARRAY_PTR(rows[i]);
39
- if(TYPE(row[j]) != T_FIXNUM)
40
- return 0;
41
- }
42
- }
43
-
44
- return 1;
45
- }
46
-
47
- /* initialize an INTMASK from a ruby array */
48
-
49
- static INTMASK*
50
- mask_ary2imask(VALUE coeffs)
51
- {
52
- INTMASK *msk;
53
- VALUE row, *rows = RARRAY_PTR(coeffs);
54
- int i, j, num_cols, num_rows = RARRAY_LEN(coeffs);
55
-
56
- num_cols = RARRAY_LEN(rows[0]);
57
- if( !(msk = im_create_imask("mask_initialize_imask", num_cols, num_rows)) )
58
- vips_lib_error();
59
-
60
- for(i = 0; i < num_rows; i++) {
61
- row = rows[i];
62
- for(j = 0; j < RARRAY_LEN(row) && j < num_cols; j++)
63
- msk->coeff[i * num_cols + j] = NUM2INT(RARRAY_PTR(row)[j]);
64
- }
65
-
66
- return msk;
67
- }
68
-
69
- static DOUBLEMASK*
70
- mask_ary2dmask(VALUE coeffs)
71
- {
72
- DOUBLEMASK *msk;
73
- VALUE row, *rows = RARRAY_PTR(coeffs);
74
- int i, j, num_cols, num_rows = RARRAY_LEN(coeffs);
75
-
76
- num_cols = RARRAY_LEN(rows[0]);
77
- if (!(msk = im_create_dmask("mask_ary2dmask", num_cols, num_rows)))
78
- vips_lib_error();
79
-
80
- for(i = 0; i < num_rows; i++) {
81
- row = rows[i];
82
- for(j = 0; j < RARRAY_LEN(row) && j < num_cols; j++)
83
- msk->coeff[i * num_cols + j] = NUM2DBL(RARRAY_PTR(row)[j]);
84
- }
85
-
86
- return msk;
87
- }
88
-
89
- /*
90
- * call-seq:
91
- * Mask.new(coeffs, scale=1, offset=0) -> mask
92
- *
93
- * Create a new Mask object. <i>coeffs</i> is a two-dimensional array where
94
- * every row must have the same length. Note that some methods require a mask
95
- * where all values in <i>coeffs</i> are whole integers.
96
- */
97
- static VALUE
98
- mask_initialize(int argc, VALUE *argv, VALUE obj)
99
- {
100
- VALUE coeffs, scale, offset;
101
- vipsMask *msk;
102
- Data_Get_Struct(obj, vipsMask, msk);
103
-
104
- rb_scan_args(argc, argv, "12", &coeffs, &scale, &offset);
105
-
106
- if (NIL_P(scale))
107
- scale = INT2NUM(1);
108
-
109
- if (NIL_P(offset))
110
- offset = INT2NUM(0);
111
-
112
- if(TYPE(scale) == T_FIXNUM && TYPE(offset) == T_FIXNUM &&
113
- ary_is_int_2d(coeffs)) {
114
- msk->imask = mask_ary2imask(coeffs);
115
- msk->imask->scale = NUM2INT(scale);
116
- msk->imask->offset = NUM2INT(offset);
117
- }
118
-
119
- msk->dmask = mask_ary2dmask(coeffs);
120
- msk->dmask->scale = NUM2DBL(scale);
121
- msk->dmask->offset = NUM2DBL(offset);
122
-
123
- return obj;
124
- }
125
-
126
- /*
127
- * call-seq:
128
- * msk.xsize -> number
129
- *
130
- * Retrieve the number of columns in the mask.
131
- */
132
-
133
- static VALUE
134
- mask_xsize(VALUE obj)
135
- {
136
- vipsMask *msk;
137
- Data_Get_Struct(obj, vipsMask, msk);
138
- return INT2FIX(msk->dmask->xsize);
139
- }
140
-
141
- /*
142
- * call-seq:
143
- * msk.ysize -> number
144
- *
145
- * Retrieve the number of rows in the mask.
146
- */
147
-
148
- static VALUE
149
- mask_ysize(VALUE obj)
150
- {
151
- vipsMask *msk;
152
- Data_Get_Struct(obj, vipsMask, msk);
153
- return INT2FIX(msk->dmask->ysize);
154
- }
155
-
156
- /*
157
- * call-seq:
158
- * msk.scale -> number
159
- *
160
- * Retrieve the scale of the mask.
161
- */
162
-
163
- static VALUE
164
- mask_scale(VALUE obj)
165
- {
166
- vipsMask *msk;
167
- Data_Get_Struct(obj, vipsMask, msk);
168
- return msk->imask ? INT2FIX(msk->imask->scale) : DBL2NUM(msk->dmask->scale);
169
- }
170
-
171
- /*
172
- * call-seq:
173
- * msk.offset -> number
174
- *
175
- * Retrieve the offset of the mask.
176
- */
177
-
178
- static VALUE
179
- mask_offset(VALUE obj)
180
- {
181
- vipsMask *msk;
182
- Data_Get_Struct(obj, vipsMask, msk);
183
- return msk->imask ? INT2FIX(msk->imask->offset) : DBL2NUM(msk->dmask->offset);
184
- }
185
-
186
- VALUE
187
- imask2rb(INTMASK *msk)
188
- {
189
- int i, j;
190
- VALUE row, rows = rb_ary_new2(msk->ysize);
191
-
192
- for(i = 0; i < msk->ysize; i++) {
193
- row = rb_ary_new2(msk->xsize);
194
- rb_ary_push(rows, row);
195
- for(j = 0; j < msk->xsize; j++) {
196
- rb_ary_push(row, INT2FIX(msk->coeff[i * msk->xsize + j]));
197
- }
198
- }
199
-
200
- return rows;
201
- }
202
-
203
- VALUE
204
- dmask2rb(DOUBLEMASK *msk)
205
- {
206
- int i, j;
207
- VALUE row, rows = rb_ary_new2(msk->ysize);
208
-
209
- for(i = 0; i < msk->ysize; i++) {
210
- row = rb_ary_new2(msk->xsize);
211
- rb_ary_push(rows, row);
212
- for(j = 0; j < msk->xsize; j++) {
213
- rb_ary_push(row, DBL2NUM(msk->coeff[i * msk->xsize + j]));
214
- }
215
- }
216
-
217
- return rows;
218
- }
219
-
220
- /*
221
- * call-seq:
222
- * msk.coeff -> array
223
- *
224
- * Retrieve the two-dimensional array of coefficients for the mask.
225
- */
226
-
227
- static VALUE
228
- mask_coeff(VALUE obj)
229
- {
230
- vipsMask *msk;
231
- Data_Get_Struct(obj, vipsMask, msk);
232
- if(msk->imask)
233
- return imask2rb(msk->imask);
234
- else
235
- return dmask2rb(msk->dmask);
236
- }
237
-
238
- /*
239
- * call-seq:
240
- * msk.int? -> true or false
241
- *
242
- * Indicate whether all coefficients, the scale and the offset in the mask are
243
- * integers. Some methods require an all-integer mask.
244
- */
245
-
246
- static VALUE
247
- mask_int_p(VALUE obj)
248
- {
249
- vipsMask *msk;
250
- Data_Get_Struct(obj, vipsMask, msk);
251
- if(msk->imask)
252
- return Qtrue;
253
-
254
- return Qfalse;
255
- }
256
-
257
- void
258
- mask_arg2mask(VALUE arg, INTMASK **imask, DOUBLEMASK **dmask)
259
- {
260
- INTMASK *imask_t = NULL;
261
- DOUBLEMASK *dmask_t = NULL;
262
- vipsMask *data;
263
- const char *errstr;
264
-
265
- if (TYPE(arg) == T_ARRAY) {
266
- if (imask && ary_is_int_2d(arg))
267
- imask_t = mask_ary2imask(arg);
268
- else if (dmask)
269
- dmask_t = mask_ary2dmask(arg);
270
- } else if (CLASS_OF(arg) == cVIPSMask) {
271
- Data_Get_Struct(arg, vipsMask, data);
272
-
273
- if (imask)
274
- imask_t = data->imask;
275
- if (dmask)
276
- dmask_t = data->dmask;
277
- }
278
-
279
- if (!imask_t && !dmask_t) {
280
- if (imask && dmask)
281
- errstr = "Expected an array or a Mask";
282
- else
283
- errstr = "Expected an int array or an int Mask";
284
-
285
- rb_raise(rb_eArgError, "%s", errstr);
286
- }
287
-
288
- if (imask)
289
- *imask = imask_t;
290
-
291
- if (dmask)
292
- *dmask = dmask_t;
293
- }
294
-
295
- /*
296
- * call-seq:
297
- * msk.int? -> true or false
298
- *
299
- * Create a one-band, band format :DOUBLE image based on mask *self*.
300
- */
301
-
302
- static VALUE
303
- mask_to_image(VALUE obj)
304
- {
305
- vipsMask *msk;
306
-
307
- OutImg(obj, new, data, im);
308
- Data_Get_Struct(obj, vipsMask, msk);
309
-
310
- if (im_mask2vips(msk->dmask, im))
311
- vips_lib_error();
312
-
313
- return new;
314
- }
315
-
316
- /*
317
- * VIPS uses masks for various operations. A vips mask is a two-dimensional
318
- * array with a scale and an offset.
319
- *
320
- * All operations that accept a Mask object also accept an array, in which case
321
- * scale defaults to 1 and offset to zero.
322
- *
323
- * Some vips operations require that all values in the mask are integer values.
324
- * These operations will raise an exception if given a mask that contains
325
- * any float values.
326
- */
327
-
328
- void
329
- init_Mask( void )
330
- {
331
- cVIPSMask = rb_define_class_under(mVIPS, "Mask", rb_cObject);
332
-
333
- rb_define_alloc_func(cVIPSMask, mask_alloc);
334
- rb_define_method(cVIPSMask, "initialize", mask_initialize, -1);
335
- rb_define_method(cVIPSMask, "xsize", mask_xsize, 0);
336
- rb_define_method(cVIPSMask, "ysize", mask_ysize, 0);
337
- rb_define_method(cVIPSMask, "scale", mask_scale, 0);
338
- rb_define_method(cVIPSMask, "offset", mask_offset, 0);
339
- rb_define_method(cVIPSMask, "coeff", mask_coeff, 0);
340
- rb_define_method(cVIPSMask, "int?", mask_int_p, 0);
341
- rb_define_method(cVIPSMask, "to_image", mask_to_image, 0);
342
-
343
- #if 0
344
- VALUE mVIPS = rb_define_module("VIPS");
345
- #endif
346
- }
347
-