ruby-vips 0.3.14 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
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
data/ext/mask.h DELETED
@@ -1,18 +0,0 @@
1
- #ifndef RUBY_VIPS_MASK_H
2
- #define RUBY_VIPS_MASK_H
3
-
4
- extern VALUE cVIPSMask;
5
-
6
- struct _vipsMask {
7
- INTMASK *imask;
8
- DOUBLEMASK *dmask;
9
- };
10
- typedef struct _vipsMask vipsMask;
11
-
12
- VALUE mask_alloc(VALUE);
13
- VALUE imask2rb(INTMASK*);
14
- VALUE dmask2rb(DOUBLEMASK*);
15
- void mask_arg2mask(VALUE, INTMASK**, DOUBLEMASK**);
16
- void init_Mask( void );
17
-
18
- #endif
@@ -1,261 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- ID id_iv__vips_fmt;
4
-
5
- VipsFormatClass*
6
- reader_get_fmt_class(VALUE klass)
7
- {
8
- VipsFormatClass *fmt_class;
9
- VALUE nickname_v;
10
- char *nickname;
11
-
12
- nickname_v = rb_ivar_get(klass, id_iv__vips_fmt);
13
- if (NIL_P(nickname_v))
14
- return NULL;
15
-
16
- nickname = StringValuePtr(nickname_v);
17
-
18
- if (!(fmt_class = (VipsFormatClass*)vips_class_find("VipsFormat", nickname)))
19
- return NULL;
20
-
21
- return fmt_class;
22
- }
23
-
24
- /* :nodoc: */
25
-
26
- static VALUE
27
- reader_s_recognized_p(VALUE klass, VALUE path)
28
- {
29
- VipsFormatClass *fmt_class = reader_get_fmt_class(klass);
30
-
31
- if (fmt_class && fmt_class->is_a && fmt_class->is_a(StringValuePtr(path)))
32
- return Qtrue;
33
-
34
- return Qfalse;
35
- }
36
-
37
- /* :nodoc: */
38
-
39
- static VALUE
40
- reader_read_internal(VALUE obj, VALUE path, VALUE flags)
41
- {
42
- VipsImage *im_new;
43
-
44
- /* flags bit 1 means "sequential mode requested".
45
- */
46
- char *mode = NUM2INT(flags) & 1 ? "rs" : "rd";
47
-
48
- if (!(im_new = im_open(StringValuePtr(path), mode)))
49
- vips_lib_error();
50
-
51
- return img_init(cVIPSImage, im_new);
52
- }
53
-
54
- static VALUE
55
- jpeg_buf_internal(VALUE obj, VALUE buf, VALUE shrink, VALUE fail)
56
- {
57
- VipsImage *im_new;
58
-
59
- im_new = NULL;
60
-
61
- #if ATLEAST_VIPS( 7, 28 )
62
- buf = StringValue(buf);
63
-
64
- if (vips_jpegload_buffer(RSTRING_PTR(buf), RSTRING_LEN(buf), &im_new,
65
- "shrink", NUM2INT(shrink),
66
- "fail", NUM2INT(fail),
67
- NULL))
68
- vips_lib_error();
69
- #else
70
- rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
71
- #endif
72
-
73
- return img_init(cVIPSImage, im_new);
74
- }
75
-
76
- static VALUE
77
- magick_buf_internal(VALUE obj, VALUE buf)
78
- {
79
- VipsImage *im_new;
80
-
81
- im_new = NULL;
82
-
83
- #if ATLEAST_VIPS( 8, 2 )
84
- buf = StringValue(buf);
85
-
86
- if (!(im_new = im_open("", "p")))
87
- vips_lib_error();
88
-
89
- if (im_bufmagick2vips(RSTRING_PTR(buf), RSTRING_LEN(buf), im_new, FALSE))
90
- vips_lib_error();
91
- #else
92
- rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
93
- #endif
94
-
95
- return img_init(cVIPSImage, im_new);
96
- }
97
-
98
- static VALUE
99
- png_buf_internal(VALUE obj, VALUE buf)
100
- {
101
- VipsImage *im_new;
102
-
103
- im_new = NULL;
104
-
105
- #if ATLEAST_VIPS( 7, 34 )
106
- buf = StringValue(buf);
107
-
108
- if (vips_pngload_buffer(RSTRING_PTR(buf), RSTRING_LEN(buf), &im_new,
109
- NULL))
110
- vips_lib_error();
111
- #else
112
- rb_raise(eVIPSError, "This method is not implemented in your version of VIPS");
113
- #endif
114
-
115
- return img_init(cVIPSImage, im_new);
116
- }
117
-
118
- /* :nodoc: */
119
-
120
- static VALUE
121
- raw_read_internal(VALUE obj, VALUE path, VALUE width, VALUE height, VALUE bpp,
122
- VALUE offset)
123
- {
124
- VipsImage *im_new;
125
-
126
- if (!(im_new = im_open(StringValuePtr(path), "p")))
127
- vips_lib_error();
128
- if (im_raw2vips(StringValuePtr(path), im_new,
129
- NUM2INT(width), NUM2INT(height), NUM2INT(bpp), NUM2INT(offset))) {
130
- im_close(im_new);
131
- vips_lib_error();
132
- }
133
-
134
- return img_init(cVIPSImage, im_new);
135
- }
136
-
137
- static VALUE
138
- magick_read_internal(VALUE obj, VALUE path, VALUE flags)
139
- {
140
- VipsImage *im_new;
141
-
142
- if (!(im_new = im_open(StringValuePtr(path), "p")))
143
- vips_lib_error();
144
- if (im_magick2vips(StringValuePtr(path), im_new)) {
145
- im_close(im_new);
146
- vips_lib_error();
147
- }
148
-
149
- return img_init(cVIPSImage, im_new);
150
- }
151
-
152
- static void
153
- reader_fmt_set(VALUE klass, const char* val)
154
- {
155
- rb_ivar_set(klass, id_iv__vips_fmt, rb_str_new_cstr(val));
156
- }
157
-
158
- /*
159
- * Base class for image format readers.
160
- */
161
-
162
- void
163
- init_Reader(void)
164
- {
165
- id_iv__vips_fmt = rb_intern("@_vips_fmt");
166
-
167
- VALUE reader = rb_define_class_under(mVIPS, "Reader", rb_cObject);
168
-
169
- /* We used to allow header methods on VIPS::Reader, we don't any more
170
- *
171
- * lib/vips/reader.rb includes a few header methods for back compat
172
- *
173
- rb_include_module(reader, mVIPSHeader);
174
- */
175
- rb_define_alloc_func(reader, img_alloc);
176
-
177
- rb_define_singleton_method(reader, "recognized?", reader_s_recognized_p, 1);
178
- rb_define_private_method(reader, "read_internal", reader_read_internal, 2);
179
-
180
- /*
181
- * Read JPEG images.
182
- */
183
-
184
- VALUE jpeg_reader = rb_define_class_under(mVIPS, "JPEGReader", reader);
185
- rb_define_private_method(jpeg_reader, "buf_internal", jpeg_buf_internal, 3);
186
- reader_fmt_set(jpeg_reader, "jpeg");
187
-
188
- /*
189
- * Read TIFF images.
190
- */
191
-
192
- VALUE tiff_reader = rb_define_class_under(mVIPS, "TIFFReader", reader);
193
- reader_fmt_set(tiff_reader, "tiff");
194
-
195
- /*
196
- * Read PPM images.
197
- */
198
-
199
- VALUE ppm_reader = rb_define_class_under(mVIPS, "PPMReader", reader);
200
- reader_fmt_set(ppm_reader, "ppm");
201
-
202
- /*
203
- * Read PNG images.
204
- */
205
-
206
- VALUE png_reader = rb_define_class_under(mVIPS, "PNGReader", reader);
207
- rb_define_private_method(png_reader, "buf_internal", png_buf_internal, 1);
208
- reader_fmt_set(png_reader, "png");
209
-
210
- /*
211
- * Read CSV images.
212
- */
213
-
214
- VALUE csv_reader = rb_define_class_under(mVIPS, "CSVReader", reader);
215
- reader_fmt_set(csv_reader, "csv");
216
-
217
- /*
218
- * Read EXR images.
219
- */
220
-
221
- VALUE exr_reader = rb_define_class_under(mVIPS, "EXRReader", reader);
222
- reader_fmt_set(exr_reader, "exr");
223
-
224
- /*
225
- * Read native VIPS images.
226
- */
227
-
228
- VALUE vips_reader = rb_define_class_under(mVIPS, "VIPSReader", reader);
229
- reader_fmt_set(vips_reader, "vips");
230
-
231
- /*
232
- * Read images using a magick library.
233
- */
234
-
235
- VALUE magick_reader = rb_define_class_under(mVIPS, "MagickReader", reader);
236
- rb_define_private_method(magick_reader, "read_internal", magick_read_internal, 2);
237
- reader_fmt_set(magick_reader, "magick");
238
-
239
- magick_reader = rb_define_class_under(mVIPS, "MagickReader", reader);
240
- rb_define_private_method(magick_reader, "buf_internal", magick_buf_internal, 1);
241
- reader_fmt_set(magick_reader, "magick");
242
-
243
- /*
244
- * Read Analyze images.
245
- */
246
-
247
- VALUE analyze_reader = rb_define_class_under(mVIPS, "AnalyzeReader", reader);
248
- reader_fmt_set(analyze_reader, "analyze");
249
-
250
- /*
251
- * Read RAW images.
252
- */
253
-
254
- VALUE raw_reader = rb_define_class_under(mVIPS, "RAWReader", reader);
255
- rb_define_private_method(raw_reader, "read_internal", raw_read_internal, 5);
256
- reader_fmt_set(raw_reader, "raw");
257
-
258
- #if 0
259
- VALUE mVIPS = rb_define_module("VIPS");
260
- #endif
261
- }
@@ -1,2 +0,0 @@
1
- void init_Reader(void);
2
-
@@ -1,188 +0,0 @@
1
- #include "ruby_vips.h"
2
-
3
- /* vips-7.26.3 and earlier 7.26 (used on Ubuntu 12.04) had a broken
4
- * vips_class_map_all(). ruby_vips.h turns on NEED_ruby_vips_class_map_all if
5
- * we need to define our own, working version.
6
- */
7
- #ifdef NEED_ruby_vips_class_map_all
8
- static void *
9
- ruby_vips_type_map( GType base, VipsTypeMap2 fn, void *a, void *b )
10
- {
11
- GType *child;
12
- guint n_children;
13
- unsigned int i;
14
- void *result;
15
-
16
- child = g_type_children( base, &n_children );
17
- result = NULL;
18
- for( i = 0; i < n_children && !result; i++ )
19
- result = fn( child[i], a, b );
20
- g_free( child );
21
-
22
- return( result );
23
- }
24
-
25
- void *
26
- ruby_vips_class_map_all( GType type, VipsClassMap fn, void *a )
27
- {
28
- void *result;
29
-
30
- if( !G_TYPE_IS_ABSTRACT( type ) ) {
31
- if( (result = fn(
32
- VIPS_OBJECT_CLASS( g_type_class_ref( type ) ), a )) )
33
- return( result );
34
- }
35
-
36
- if( (result = vips_type_map( type,
37
- (VipsTypeMap2) ruby_vips_class_map_all, fn, a )) )
38
- return( result );
39
-
40
- return( NULL );
41
- }
42
- #endif /*NEED_ruby_vips_class_map_all*/
43
-
44
- VALUE mVIPS, eVIPSError;
45
-
46
- void
47
- vips_lib_error()
48
- {
49
- VALUE vips_error = rb_str_new2(im_error_buffer());
50
- im_error_clear();
51
- rb_raise(eVIPSError, "VIPS error: %s", RSTRING_PTR(vips_error));
52
- }
53
-
54
- static VALUE
55
- vips_s_version_string()
56
- {
57
- return rb_str_new2(im_version_string());
58
- }
59
-
60
- static VALUE
61
- vips_s_version_array()
62
- {
63
- VALUE arr = rb_ary_new2(3);
64
- int i;
65
-
66
- for(i = 0; i < 3; i++)
67
- rb_ary_push(arr, INT2FIX(im_version(i)));
68
-
69
- return arr;
70
- }
71
-
72
- /*
73
- * call-seq:
74
- * VIPS.debug_info -> string
75
- *
76
- * This will print internal debugging information from VIPS, including memory
77
- * allocation information.
78
- */
79
- static VALUE
80
- vips_s_debug_info(VALUE obj)
81
- {
82
- im__print_all();
83
- return Qnil;
84
- }
85
-
86
- /*
87
- * call-seq:
88
- * VIPS.thread_shutdown -> string
89
- *
90
- * Free any thread-private data and flush any profiling information.
91
- *
92
- * This function needs to be called when a thread that has been using vips
93
- * exits. It is called for you by vips_shutdown() and for any threads created
94
- * by vips_g_thread_new().
95
- *
96
- * You will need to call it from threads created in other ways. If you do
97
- * not call it, vips will generate an error message.
98
- *
99
- * May be called many times.
100
- */
101
- static VALUE
102
- vips_s_thread_shutdown(VALUE obj)
103
- {
104
- vips_thread_shutdown();
105
- return Qnil;
106
- }
107
-
108
- /*
109
- * Build a call to im_init_world() and pass command line options to vips. This
110
- * sets some library wide options.
111
- */
112
-
113
- static void
114
- init_vips_library()
115
- {
116
- GOptionContext *context;
117
- GError *error = NULL;
118
- int i, argc;
119
- char **argv;
120
- VALUE argv_0, argv_v;
121
-
122
- argv_0 = rb_gv_get("0");
123
-
124
- if (NIL_P(argv_0))
125
- im_init_world("");
126
- else
127
- im_init_world(RSTRING_PTR(argv_0));
128
-
129
- argv_v = rb_const_get(rb_mKernel, rb_intern("ARGV"));
130
-
131
- if (!NIL_P(argv_v))
132
- {
133
- argc = RARRAY_LEN(argv_v) + 1;
134
- argv = ALLOC_N(char*, argc);
135
-
136
- argv[0] = RSTRING_PTR(argv_0);
137
-
138
- for (i=0; i < argc - 1; i++)
139
- argv[i+1] = RSTRING_PTR(RARRAY_PTR(argv_v)[i]);
140
-
141
- context = g_option_context_new("- ruby-vips");
142
- g_option_context_set_ignore_unknown_options(context, TRUE);
143
-
144
- g_option_context_add_group(context, im_get_option_group());
145
-
146
- g_option_context_parse(context, &argc, &argv, &error);
147
- g_option_context_free(context);
148
-
149
- xfree(argv);
150
- }
151
-
152
- #if ATLEAST_VIPS( 7, 28 )
153
- /* We use the vips7 interface, so the vips8 cache will not help us.
154
- * Disable it and save 100mb or so of memory in vips-7.28 and later.
155
- */
156
- vips_cache_set_max_mem( 0 );
157
- #endif
158
- }
159
-
160
- /*
161
- * The VIPS module namespaces all ruby-vips objects.
162
- */
163
-
164
- void
165
- Init_vips_ext()
166
- {
167
- init_vips_library();
168
-
169
- mVIPS = rb_define_module("VIPS");
170
- eVIPSError = rb_define_class_under(mVIPS, "Error", rb_eStandardError);
171
-
172
- rb_define_singleton_method(mVIPS, "debug_info", vips_s_debug_info, 0);
173
-
174
- rb_define_singleton_method(mVIPS, "thread_shutdown", vips_s_thread_shutdown, 0);
175
-
176
- /* Vips Library version string */
177
- rb_define_const(mVIPS, "LIB_VERSION", vips_s_version_string());
178
-
179
- /* Vips Library version as a 3-element array */
180
- rb_define_const(mVIPS, "LIB_VERSION_ARRAY", vips_s_version_array());
181
-
182
- init_Header();
183
- init_Image();
184
- init_Mask();
185
- init_Interpolator();
186
- init_Writer();
187
- init_Reader();
188
- }