ruby-vips 0.2.1 → 0.3.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.
@@ -12,3 +12,4 @@ VALUE img_correl(VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE, VALUE);
12
12
  VALUE img_remosaic(VALUE, VALUE, VALUE);
13
13
  VALUE img_align_bands(VALUE);
14
14
  VALUE img_maxpos_subpel(VALUE);
15
+ void init_Image_mosaicing(void);
@@ -1,6 +1,4 @@
1
1
  #include "ruby_vips.h"
2
- #include "image.h"
3
- #include "image_relational.h"
4
2
 
5
3
  static VALUE
6
4
  img_equal_const(int argc, VALUE *argv, VALUE obj)
@@ -1,8 +1,4 @@
1
1
  #include "ruby_vips.h"
2
- #include "image.h"
3
- #include "interpolator.h"
4
- #include "header.h"
5
- #include "image_resample.h"
6
2
 
7
3
  /*
8
4
  * call-seq:
@@ -89,7 +89,7 @@ interp_description(VALUE obj)
89
89
  */
90
90
 
91
91
  void
92
- init_Interpolator()
92
+ init_Interpolator(void)
93
93
  {
94
94
  cVIPSInterpolator = rb_define_class_under(mVIPS, "Interpolator", rb_cObject);
95
95
 
@@ -2,5 +2,6 @@
2
2
  #define RUBY_VIPS_INTERPOLATOR_H
3
3
 
4
4
  VipsInterpolate* interp_lookup(VALUE);
5
+ void init_Interpolator(void);
5
6
 
6
7
  #endif
data/ext/mask.c CHANGED
@@ -1,6 +1,4 @@
1
1
  #include "ruby_vips.h"
2
- #include "mask.h"
3
- #include "image.h"
4
2
 
5
3
  VALUE cVIPSMask;
6
4
 
@@ -328,7 +326,7 @@ mask_to_image(VALUE obj)
328
326
  */
329
327
 
330
328
  void
331
- init_Mask()
329
+ init_Mask( void )
332
330
  {
333
331
  cVIPSMask = rb_define_class_under(mVIPS, "Mask", rb_cObject);
334
332
 
data/ext/mask.h CHANGED
@@ -13,5 +13,6 @@ VALUE mask_alloc(VALUE);
13
13
  VALUE imask2rb(INTMASK*);
14
14
  VALUE dmask2rb(DOUBLEMASK*);
15
15
  void mask_arg2mask(VALUE, INTMASK**, DOUBLEMASK**);
16
+ void init_Mask( void );
16
17
 
17
18
  #endif
@@ -1,6 +1,4 @@
1
1
  #include "ruby_vips.h"
2
- #include "image.h"
3
- #include "header.h"
4
2
 
5
3
  ID id_iv__vips_fmt;
6
4
 
@@ -17,7 +15,7 @@ reader_get_fmt_class(VALUE klass)
17
15
 
18
16
  nickname = StringValuePtr(nickname_v);
19
17
 
20
- if (!(fmt_class = (VipsFormatClass*)vips_class_find("VipsFormat", nickname)))
18
+ if (!(fmt_class = (VipsFormatClass*)vips_class_find("VipsFormat", nickname)))
21
19
  return NULL;
22
20
 
23
21
  return fmt_class;
@@ -25,31 +23,6 @@ reader_get_fmt_class(VALUE klass)
25
23
 
26
24
  /* :nodoc: */
27
25
 
28
- static VALUE
29
- reader_read_header(VALUE obj, VALUE path)
30
- {
31
- VipsImage *im_new;
32
- VipsFormatClass *fmt_class = reader_get_fmt_class(CLASS_OF(obj));
33
- GetImg(obj, data, im);
34
-
35
- if (!fmt_class)
36
- return Qfalse;
37
-
38
- if (!(im_new = (VipsImage*)im_open("reader_read_header", "p")))
39
- vips_lib_error();
40
-
41
- if (fmt_class->header(StringValuePtr(path), im_new)) {
42
- im_close(im_new);
43
- vips_lib_error();
44
- }
45
-
46
- data->in = im_new;
47
-
48
- return Qtrue;
49
- }
50
-
51
- /* :nodoc: */
52
-
53
26
  static VALUE
54
27
  reader_s_recognized_p(VALUE klass, VALUE path)
55
28
  {
@@ -64,118 +37,18 @@ reader_s_recognized_p(VALUE klass, VALUE path)
64
37
  /* :nodoc: */
65
38
 
66
39
  static VALUE
67
- reader_read_internal(VALUE obj, VALUE path)
68
- {
69
- VipsImage *im;
70
-
71
- if (!(im = im_open(StringValuePtr(path), "r")))
72
- vips_lib_error();
73
-
74
- return img_init(cVIPSImage, im);
75
- }
76
-
77
- /* :nodoc: */
78
-
79
- static VALUE
80
- jpeg_read_internal(VALUE obj, VALUE path)
81
- {
82
- OutPartial(new, data, im);
83
-
84
- if (im_jpeg2vips(StringValuePtr(path), im))
85
- vips_lib_error();
86
-
87
- return new;
88
- }
89
-
90
- /* :nodoc: */
91
-
92
- static VALUE
93
- tiff_read_internal(VALUE obj, VALUE path)
94
- {
95
- OutPartial(new, data, im);
96
-
97
- if (im_tiff2vips(StringValuePtr(path), im))
98
- vips_lib_error();
99
-
100
- return new;
101
- }
102
-
103
- /* :nodoc: */
104
-
105
- static VALUE
106
- magick_read_internal(VALUE obj, VALUE path)
107
- {
108
- OutPartial(new, data, im);
109
-
110
- if (im_magick2vips(StringValuePtr(path), im))
111
- vips_lib_error();
112
-
113
- return new;
114
- }
115
-
116
- /* :nodoc: */
117
-
118
- static VALUE
119
- exr_read_internal(VALUE obj, VALUE path)
120
- {
121
- OutPartial(new, data, im);
122
-
123
- if (im_exr2vips(StringValuePtr(path), im))
124
- vips_lib_error();
125
-
126
- return new;
127
- }
128
-
129
- /* :nodoc: */
130
-
131
- static VALUE
132
- ppm_read_internal(VALUE obj, VALUE path)
133
- {
134
- OutPartial(new, data, im);
135
-
136
- if (im_ppm2vips(StringValuePtr(path), im))
137
- vips_lib_error();
138
-
139
- return new;
140
- }
141
-
142
- /* :nodoc: */
143
-
144
- static VALUE
145
- analyze_read_internal(VALUE obj, VALUE path)
146
- {
147
- OutPartial(new, data, im);
148
-
149
- if (im_analyze2vips(StringValuePtr(path), im))
150
- vips_lib_error();
151
-
152
- return new;
153
- }
154
-
155
- /* :nodoc: */
156
-
157
- static VALUE
158
- csv_read_internal(VALUE obj, VALUE path)
40
+ reader_read_internal(VALUE obj, VALUE path, VALUE flags)
159
41
  {
160
- OutPartial(new, data, im);
161
-
162
- if (im_csv2vips(StringValuePtr(path), im))
163
- vips_lib_error();
42
+ VipsImage *im_new;
164
43
 
165
- return new;
166
- }
167
-
168
- /* :nodoc: */
44
+ /* flags bit 1 means "sequential mode requested".
45
+ */
46
+ char *mode = NUM2INT(flags) & 1 ? "rs" : "rd";
169
47
 
170
- static VALUE
171
- png_read_internal(VALUE obj, VALUE path)
172
- {
173
- OutPartial(new, data, im);
174
-
175
- if (im_png2vips(StringValuePtr(path), im))
48
+ if (!(im_new = im_open(StringValuePtr(path), mode)))
176
49
  vips_lib_error();
177
50
 
178
- return new;
51
+ return img_init(cVIPSImage, im_new);
179
52
  }
180
53
 
181
54
  /* :nodoc: */
@@ -184,26 +57,17 @@ static VALUE
184
57
  raw_read_internal(VALUE obj, VALUE path, VALUE width, VALUE height, VALUE bpp,
185
58
  VALUE offset)
186
59
  {
187
- OutPartial(new, data, im);
60
+ VipsImage *im_new;
188
61
 
189
- if (im_raw2vips(StringValuePtr(path), im, NUM2INT(width), NUM2INT(height),
190
- NUM2INT(bpp), NUM2INT(offset)))
62
+ if (!(im_new = im_open(StringValuePtr(path), "p")))
191
63
  vips_lib_error();
192
-
193
- return new;
194
- }
195
-
196
- /* :nodoc: */
197
-
198
- static VALUE
199
- vips_read_internal(VALUE obj, VALUE path)
200
- {
201
- VipsImage *im;
202
-
203
- if (!(im = (VipsImage *)im_open(StringValuePtr(path),"r")))
64
+ if (im_raw2vips(StringValuePtr(path), im_new,
65
+ NUM2INT(width), NUM2INT(height), NUM2INT(bpp), NUM2INT(offset))) {
66
+ im_close(im_new);
204
67
  vips_lib_error();
68
+ }
205
69
 
206
- return img_init(cVIPSImage, im);
70
+ return img_init(cVIPSImage, im_new);
207
71
  }
208
72
 
209
73
  static void
@@ -217,7 +81,7 @@ reader_fmt_set(VALUE klass, const char* val)
217
81
  */
218
82
 
219
83
  void
220
- init_Reader()
84
+ init_Reader(void)
221
85
  {
222
86
  id_iv__vips_fmt = rb_intern("@_vips_fmt");
223
87
 
@@ -226,15 +90,13 @@ init_Reader()
226
90
  rb_define_alloc_func(reader, img_alloc);
227
91
 
228
92
  rb_define_singleton_method(reader, "recognized?", reader_s_recognized_p, 1);
229
- rb_define_private_method(reader, "read_header", reader_read_header, 1);
230
- rb_define_private_method(reader, "read_internal", reader_read_internal, 1);
93
+ rb_define_private_method(reader, "read_internal", reader_read_internal, 2);
231
94
 
232
95
  /*
233
96
  * Read JPEG images.
234
97
  */
235
98
 
236
99
  VALUE jpeg_reader = rb_define_class_under(mVIPS, "JPEGReader", reader);
237
- rb_define_private_method(jpeg_reader, "read_internal", jpeg_read_internal, 1);
238
100
  reader_fmt_set(jpeg_reader, "jpeg");
239
101
 
240
102
  /*
@@ -242,7 +104,6 @@ init_Reader()
242
104
  */
243
105
 
244
106
  VALUE tiff_reader = rb_define_class_under(mVIPS, "TIFFReader", reader);
245
- rb_define_private_method(tiff_reader, "read_internal", tiff_read_internal, 1);
246
107
  reader_fmt_set(tiff_reader, "tiff");
247
108
 
248
109
  /*
@@ -250,7 +111,6 @@ init_Reader()
250
111
  */
251
112
 
252
113
  VALUE ppm_reader = rb_define_class_under(mVIPS, "PPMReader", reader);
253
- rb_define_private_method(ppm_reader, "read_internal", ppm_read_internal, 1);
254
114
  reader_fmt_set(ppm_reader, "ppm");
255
115
 
256
116
  /*
@@ -258,7 +118,6 @@ init_Reader()
258
118
  */
259
119
 
260
120
  VALUE png_reader = rb_define_class_under(mVIPS, "PNGReader", reader);
261
- rb_define_private_method(png_reader, "read_internal", png_read_internal, 1);
262
121
  reader_fmt_set(png_reader, "png");
263
122
 
264
123
  /*
@@ -266,7 +125,6 @@ init_Reader()
266
125
  */
267
126
 
268
127
  VALUE csv_reader = rb_define_class_under(mVIPS, "CSVReader", reader);
269
- rb_define_private_method(csv_reader, "read_internal", csv_read_internal, 1);
270
128
  reader_fmt_set(csv_reader, "csv");
271
129
 
272
130
  /*
@@ -274,7 +132,6 @@ init_Reader()
274
132
  */
275
133
 
276
134
  VALUE exr_reader = rb_define_class_under(mVIPS, "EXRReader", reader);
277
- rb_define_private_method(exr_reader, "read_internal", exr_read_internal, 1);
278
135
  reader_fmt_set(exr_reader, "exr");
279
136
 
280
137
  /*
@@ -282,7 +139,6 @@ init_Reader()
282
139
  */
283
140
 
284
141
  VALUE vips_reader = rb_define_class_under(mVIPS, "VIPSReader", reader);
285
- rb_define_private_method(vips_reader, "read_internal", vips_read_internal, 1);
286
142
  reader_fmt_set(vips_reader, "vips");
287
143
 
288
144
  /*
@@ -290,7 +146,6 @@ init_Reader()
290
146
  */
291
147
 
292
148
  VALUE magick_reader = rb_define_class_under(mVIPS, "MagickReader", reader);
293
- rb_define_private_method(magick_reader, "read_internal", magick_read_internal, 1);
294
149
  reader_fmt_set(magick_reader, "magick");
295
150
 
296
151
  /*
@@ -298,7 +153,6 @@ init_Reader()
298
153
  */
299
154
 
300
155
  VALUE analyze_reader = rb_define_class_under(mVIPS, "AnalyzeReader", reader);
301
- rb_define_private_method(analyze_reader, "read_internal", analyze_read_internal, 1);
302
156
  reader_fmt_set(analyze_reader, "analyze");
303
157
 
304
158
  /*
@@ -0,0 +1,2 @@
1
+ void init_Reader(void);
2
+
@@ -42,19 +42,6 @@ vips_s_debug_info(VALUE obj)
42
42
  return Qnil;
43
43
  }
44
44
 
45
- /*
46
- * This method will kill the ruby interpreter and then invokes im__print_all()
47
- * to hunt for dangling Vips allocations.
48
- */
49
- static VALUE
50
- vips_exit_info(VALUE obj)
51
- {
52
- ruby_finalize();
53
- im__print_all();
54
- exit(0);
55
- return Qnil;
56
- }
57
-
58
45
  /*
59
46
  * Build a call to im_init_world() and pass command line options to vips. This
60
47
  * sets some library wide options.
@@ -1,13 +1,18 @@
1
1
  #ifndef RUBY_VIPS_H
2
2
  #define RUBY_VIPS_H
3
3
 
4
- #include "ruby.h"
5
- #include "vips/vips.h"
4
+ #include <ruby.h>
5
+ #include <vips/vips.h>
6
6
 
7
7
  extern VALUE mVIPS, eVIPSError;
8
8
 
9
9
  void vips_lib_error();
10
10
 
11
+ /* If we're not using GNU C, elide __attribute__ */
12
+ #ifndef __GNUC__
13
+ # define __attribute__(x) /*NOTHING*/
14
+ #endif
15
+
11
16
  /* Backports from ruby 1.9.2 for ruby 1.8.7
12
17
  */
13
18
 
@@ -23,4 +28,22 @@ void vips_lib_error();
23
28
  #define rb_str_new_cstr(str) rb_str_new(str, (long)strlen(str))
24
29
  #endif
25
30
 
31
+ #include "header.h"
32
+ #include "image_arithmetic.h"
33
+ #include "image_boolean.h"
34
+ #include "image_colour.h"
35
+ #include "image_conversion.h"
36
+ #include "image_convolution.h"
37
+ #include "image_freq_filt.h"
38
+ #include "image.h"
39
+ #include "image_histograms_lut.h"
40
+ #include "image_morphology.h"
41
+ #include "image_mosaicing.h"
42
+ #include "image_relational.h"
43
+ #include "image_resample.h"
44
+ #include "interpolator.h"
45
+ #include "mask.h"
46
+ #include "reader.h"
47
+ #include "writer.h"
48
+
26
49
  #endif
@@ -1,6 +1,4 @@
1
1
  #include "ruby_vips.h"
2
- #include "image.h"
3
- #include "header.h"
4
2
 
5
3
  /* :nodoc: */
6
4
 
@@ -144,25 +142,15 @@ writer_write_internal(VALUE obj, VALUE path)
144
142
  static VALUE
145
143
  jpeg_buf_internal(VALUE obj, VALUE quality)
146
144
  {
147
- VipsImage *im_out;
148
145
  char *buf = NULL;
149
146
  int length;
150
- VALUE str;
151
147
 
152
148
  GetImg(obj, data, im);
153
149
 
154
- if (!(im_out = im_open("writer_jpeg_buf", "p")))
150
+ if (im_vips2bufjpeg(im, NULL, NUM2INT(quality), &buf, &length))
155
151
  vips_lib_error();
156
152
 
157
- if (im_vips2bufjpeg(im, im_out, NUM2INT(quality), &buf, &length)) {
158
- im_close(im_out);
159
- vips_lib_error();
160
- }
161
-
162
- str = rb_tainted_str_new(buf, length);
163
- im_close(im_out);
164
-
165
- return str;
153
+ return rb_tainted_str_new(buf, length);
166
154
  }
167
155
 
168
156
  /* :nodoc: */
@@ -210,21 +198,13 @@ static VALUE
210
198
  png_buf_internal(VALUE obj, VALUE compression, VALUE interlace)
211
199
  {
212
200
  #if IM_MAJOR_VERSION > 7 || IM_MINOR_VERSION >= 23
213
- VipsImage *im_out;
214
201
  char *buf;
215
202
  size_t length;
216
203
  GetImg(obj, data, im);
217
204
 
218
- if (!(im_out = im_open("writer_png_buf", "p")))
219
- vips_lib_error();
220
-
221
- if (im_vips2bufpng(im, im_out, NUM2INT(compression), NUM2INT(interlace),
222
- &buf, &length)) {
223
- im_close(im_out);
205
+ if (im_vips2bufpng(im, NULL, NUM2INT(compression), NUM2INT(interlace),
206
+ &buf, &length))
224
207
  vips_lib_error();
225
- }
226
-
227
- im_close(im_out);
228
208
 
229
209
  return rb_tainted_str_new(buf, length);
230
210
  #else
@@ -282,7 +262,7 @@ vips_write_internal(VALUE obj, VALUE path)
282
262
  */
283
263
 
284
264
  void
285
- init_Writer()
265
+ init_Writer(void)
286
266
  {
287
267
  VALUE writer = rb_define_class_under(mVIPS, "Writer", rb_cObject);
288
268