ruby-vips 2.0.13 → 2.0.14

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 (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +10 -0
  3. data/.rubocop_todo.yml +730 -0
  4. data/.travis.yml +13 -6
  5. data/CHANGELOG.md +8 -0
  6. data/README.md +5 -8
  7. data/Rakefile +6 -0
  8. data/VERSION +1 -1
  9. data/example/annotate.rb +2 -2
  10. data/example/daltonize8.rb +14 -14
  11. data/example/example2.rb +6 -6
  12. data/example/example3.rb +5 -5
  13. data/example/example4.rb +4 -4
  14. data/example/example5.rb +2 -2
  15. data/example/inheritance_with_refcount.rb +207 -207
  16. data/example/thumb.rb +10 -10
  17. data/example/trim8.rb +2 -2
  18. data/example/watermark.rb +14 -35
  19. data/example/wobble.rb +24 -24
  20. data/install-vips.sh +1 -1
  21. data/lib/vips.rb +335 -306
  22. data/lib/vips/access.rb +9 -9
  23. data/lib/vips/align.rb +7 -7
  24. data/lib/vips/angle.rb +8 -8
  25. data/lib/vips/angle45.rb +12 -12
  26. data/lib/vips/bandformat.rb +16 -16
  27. data/lib/vips/blend_mode.rb +34 -0
  28. data/lib/vips/coding.rb +11 -11
  29. data/lib/vips/compass_direction.rb +13 -13
  30. data/lib/vips/direction.rb +7 -7
  31. data/lib/vips/extend.rb +13 -13
  32. data/lib/vips/gobject.rb +94 -94
  33. data/lib/vips/gvalue.rb +232 -232
  34. data/lib/vips/image.rb +1329 -1335
  35. data/lib/vips/interesting.rb +10 -10
  36. data/lib/vips/interpolate.rb +51 -51
  37. data/lib/vips/interpretation.rb +25 -25
  38. data/lib/vips/kernel.rb +18 -18
  39. data/lib/vips/methods.rb +463 -283
  40. data/lib/vips/object.rb +208 -208
  41. data/lib/vips/operation.rb +323 -323
  42. data/lib/vips/operationboolean.rb +10 -10
  43. data/lib/vips/operationcomplex.rb +8 -8
  44. data/lib/vips/operationcomplex2.rb +6 -6
  45. data/lib/vips/operationcomplexget.rb +7 -7
  46. data/lib/vips/operationmath.rb +14 -14
  47. data/lib/vips/operationmath2.rb +6 -6
  48. data/lib/vips/operationrelational.rb +11 -11
  49. data/lib/vips/operationround.rb +7 -7
  50. data/lib/vips/size.rb +9 -9
  51. data/lib/vips/version.rb +1 -1
  52. data/ruby-vips.gemspec +6 -2
  53. metadata +29 -6
@@ -1,11 +1,11 @@
1
1
  module Vips
2
- # The type of access an operation has to supply.
3
- #
4
- # * `:random` means requests can come in any order.
5
- #
6
- # * `:sequential` means requests will be top-to-bottom, but with some
7
- # amount of buffering behind the read point for small non-local
8
- # accesses.
9
- class Access < Symbol
10
- end
2
+ # The type of access an operation has to supply.
3
+ #
4
+ # * `:random` means requests can come in any order.
5
+ #
6
+ # * `:sequential` means requests will be top-to-bottom, but with some
7
+ # amount of buffering behind the read point for small non-local
8
+ # accesses.
9
+ class Access < Symbol
10
+ end
11
11
  end
@@ -1,11 +1,11 @@
1
1
  module Vips
2
2
 
3
- # Various types of alignment. See {Image#join}, for example.
4
- #
5
- # * `:low` Align on the low coordinate edge
6
- # * `:centre` Align on the centre
7
- # * `:high` Align on the high coordinate edge
3
+ # Various types of alignment. See {Image#join}, for example.
4
+ #
5
+ # * `:low` Align on the low coordinate edge
6
+ # * `:centre` Align on the centre
7
+ # * `:high` Align on the high coordinate edge
8
8
 
9
- class Align < Symbol
10
- end
9
+ class Align < Symbol
10
+ end
11
11
  end
@@ -1,12 +1,12 @@
1
1
  module Vips
2
2
 
3
- # Various fixed 90 degree rotation angles. See {Image#rot}.
4
- #
5
- # * `:d0` no rotate
6
- # * `:d90` 90 degrees clockwise
7
- # * `:d180` 180 degrees
8
- # * `:d270` 90 degrees anti-clockwise
3
+ # Various fixed 90 degree rotation angles. See {Image#rot}.
4
+ #
5
+ # * `:d0` no rotate
6
+ # * `:d90` 90 degrees clockwise
7
+ # * `:d180` 180 degrees
8
+ # * `:d270` 90 degrees anti-clockwise
9
9
 
10
- class Angle < Symbol
11
- end
10
+ class Angle < Symbol
11
+ end
12
12
  end
@@ -1,16 +1,16 @@
1
1
  module Vips
2
2
 
3
- # Various fixed 45 degree rotation angles. See {Image#rot45}.
4
- #
5
- # * `:d0` no rotate
6
- # * `:d45` 45 degrees clockwise
7
- # * `:d90` 90 degrees clockwise
8
- # * `:d135` 135 degrees clockwise
9
- # * `:d180` 180 degrees
10
- # * `:d225` 135 degrees anti-clockwise
11
- # * `:d270` 90 degrees anti-clockwise
12
- # * `:d315` 45 degrees anti-clockwise
3
+ # Various fixed 45 degree rotation angles. See {Image#rot45}.
4
+ #
5
+ # * `:d0` no rotate
6
+ # * `:d45` 45 degrees clockwise
7
+ # * `:d90` 90 degrees clockwise
8
+ # * `:d135` 135 degrees clockwise
9
+ # * `:d180` 180 degrees
10
+ # * `:d225` 135 degrees anti-clockwise
11
+ # * `:d270` 90 degrees anti-clockwise
12
+ # * `:d315` 45 degrees anti-clockwise
13
13
 
14
- class Angle45 < Symbol
15
- end
14
+ class Angle45 < Symbol
15
+ end
16
16
  end
@@ -1,20 +1,20 @@
1
1
  module Vips
2
2
 
3
- # The format used for each band element. Each corresponds to a native C type
4
- # for the current machine.
5
- #
6
- # * `:notset` invalid setting
7
- # * `:uchar` unsigned char format
8
- # * `:char` char format
9
- # * `:ushort` unsigned short format
10
- # * `:short` short format
11
- # * `:uint` unsigned int format
12
- # * `:int` int format
13
- # * `:float` float format
14
- # * `:complex` complex (two floats) format
15
- # * `:double` double float format
16
- # * `:dpcomplex` double complex (two double) format
17
- class BandFormat < Symbol
18
- end
3
+ # The format used for each band element. Each corresponds to a native C type
4
+ # for the current machine.
5
+ #
6
+ # * `:notset` invalid setting
7
+ # * `:uchar` unsigned char format
8
+ # * `:char` char format
9
+ # * `:ushort` unsigned short format
10
+ # * `:short` short format
11
+ # * `:uint` unsigned int format
12
+ # * `:int` int format
13
+ # * `:float` float format
14
+ # * `:complex` complex (two floats) format
15
+ # * `:double` double float format
16
+ # * `:dpcomplex` double complex (two double) format
17
+ class BandFormat < Symbol
18
+ end
19
19
 
20
20
  end
@@ -0,0 +1,34 @@
1
+ module Vips
2
+
3
+ # Blend mode to use when compositing images. See {Image#composite}.
4
+ #
5
+ # `:clear` - where the second object is drawn, the first is removed
6
+ # `:source` - the second object is drawn as if nothing were below
7
+ # `:over` - the image shows what you would expect if you held two semi-transparent slides on top of each other
8
+ # `:in` - the first object is removed completely, the second is only drawn where the first was
9
+ # `:out` - the second is drawn only where the first isn't
10
+ # `:atop` - this leaves the first object mostly intact, but mixes both objects in the overlapping area
11
+ # `:dest` - leaves the first object untouched, the second is discarded completely
12
+ # `:dest_over` - like `:over`, but swaps the arguments
13
+ # `:dest_in` - like `:in`, but swaps the arguments
14
+ # `:dest_out` - like `:out`, but swaps the arguments
15
+ # `:dest_atop` - like `:atop`, but swaps the arguments
16
+ # `:xor` - something like a difference operator
17
+ # `:add` - a bit like adding the two images
18
+ # `:saturate` - a bit like the darker of the two
19
+ # `:multiply` - at least as dark as the darker of the two inputs
20
+ # `:screen` - at least as light as the lighter of the inputs
21
+ # `:overlay` - multiplies or screens colors, depending on the lightness
22
+ # `:darken` - the darker of each component
23
+ # `:lighten` - the lighter of each component
24
+ # `:colour_dodge` - brighten first by a factor second
25
+ # `:colour_burn` - darken first by a factor of second
26
+ # `:hard_light` - multiply or screen, depending on lightness
27
+ # `:soft_light` - darken or lighten, depending on lightness
28
+ # `:difference` - difference of the two
29
+ # `:exclusion` - somewhat like `:difference`, but lower-contrast
30
+
31
+ class BlendMode < Symbol
32
+ end
33
+ end
34
+
@@ -1,14 +1,14 @@
1
1
  module Vips
2
2
 
3
- # How pixels are coded.
4
- #
5
- # Normally, pixels are uncoded and can be manipulated as you would expect.
6
- # However some file formats code pixels for compression, and sometimes it's
7
- # useful to be able to manipulate images in the coded format.
8
- #
9
- # * `:none` pixels are not coded
10
- # * `:labq` pixels encode 3 float CIELAB values as 4 uchar
11
- # * `:rad` pixels encode 3 float RGB as 4 uchar (Radiance coding)
12
- class Coding < Symbol
13
- end
3
+ # How pixels are coded.
4
+ #
5
+ # Normally, pixels are uncoded and can be manipulated as you would expect.
6
+ # However some file formats code pixels for compression, and sometimes it's
7
+ # useful to be able to manipulate images in the coded format.
8
+ #
9
+ # * `:none` pixels are not coded
10
+ # * `:labq` pixels encode 3 float CIELAB values as 4 uchar
11
+ # * `:rad` pixels encode 3 float RGB as 4 uchar (Radiance coding)
12
+ class Coding < Symbol
13
+ end
14
14
  end
@@ -1,17 +1,17 @@
1
1
  module Vips
2
2
 
3
- # A direction on a compass used for placing images. See {Image#gravity}.
4
- #
5
- # * `:centre`
6
- # * `:north`
7
- # * `:east`
8
- # * `:south`
9
- # * `:west`
10
- # * `:north-east`
11
- # * `"south-east`
12
- # * `:south-west`
13
- # * `:north-west`
3
+ # A direction on a compass used for placing images. See {Image#gravity}.
4
+ #
5
+ # * `:centre`
6
+ # * `:north`
7
+ # * `:east`
8
+ # * `:south`
9
+ # * `:west`
10
+ # * `:"north-east"`
11
+ # * `:"south-east"`
12
+ # * `:"south-west"`
13
+ # * `:"north-west"`
14
14
 
15
- class CompassDirection < Symbol
16
- end
15
+ class CompassDirection < Symbol
16
+ end
17
17
  end
@@ -1,11 +1,11 @@
1
1
  module Vips
2
2
 
3
- # Operations like {Image#flip} need to be told whether to flip
4
- # left-right or top-bottom.
5
- #
6
- # * `:horizontal` left-right
7
- # * `:vertical` top-bottom
3
+ # Operations like {Image#flip} need to be told whether to flip
4
+ # left-right or top-bottom.
5
+ #
6
+ # * `:horizontal` left-right
7
+ # * `:vertical` top-bottom
8
8
 
9
- class Direction < Symbol
10
- end
9
+ class Direction < Symbol
10
+ end
11
11
  end
@@ -1,17 +1,17 @@
1
1
  module Vips
2
2
 
3
- # When the edges of an image are extended, you can specify
4
- # how you want the extension done.
5
- # See {Image#embed}, {Image#conv}, {Image#affine} and
6
- # so on.
7
- #
8
- # * `:black` new pixels are black, ie. all bits are zero.
9
- # * `:copy` each new pixel takes the value of the nearest edge pixel
10
- # * `:repeat` the image is tiled to fill the new area
11
- # * `:mirror` the image is reflected and tiled to reduce hash edges
12
- # * `:white` new pixels are white, ie. all bits are set
13
- # * `:background` colour set from the @background property
3
+ # When the edges of an image are extended, you can specify
4
+ # how you want the extension done.
5
+ # See {Image#embed}, {Image#conv}, {Image#affine} and
6
+ # so on.
7
+ #
8
+ # * `:black` new pixels are black, ie. all bits are zero.
9
+ # * `:copy` each new pixel takes the value of the nearest edge pixel
10
+ # * `:repeat` the image is tiled to fill the new area
11
+ # * `:mirror` the image is reflected and tiled to reduce hash edges
12
+ # * `:white` new pixels are white, ie. all bits are set
13
+ # * `:background` colour set from the @background property
14
14
 
15
- class Extend < Symbol
16
- end
15
+ class Extend < Symbol
16
+ end
17
17
  end
@@ -9,114 +9,114 @@ require 'forwardable'
9
9
 
10
10
  module GObject
11
11
 
12
- # we have a number of things we need to inherit in different ways:
13
- #
14
- # - we want to be able to subclass GObject in Ruby in a simple way
15
- # - the layouts of the nested structs need to inherit
16
- # - we need to be able to cast between structs which share a base struct
17
- # without creating new wrappers or messing up refcounting
18
- # - we need automatic gobject refcounting
19
- #
20
- # the solution is to split the class into four areas which we treat
21
- # differently:
22
- #
23
- # - we have a "wrapper" Ruby class to allow easy subclassing ... this has a
24
- # @struct member which holds the actual pointer
25
- # - we use "forwardable" to forward the various ffi methods on to the
26
- # @struct member ... we arrange things so that subclasses do not need to
27
- # do the forwarding themselves
28
- # - we have two versions of the struct: a plain one which we can use for
29
- # casting that will not change the refcounts
30
- # - and a managed one with an unref which we just use for .new
31
- # - we separate the struct layout into a separate module to avoid repeating
32
- # ourselves
33
-
34
- class GObject
35
- extend Forwardable
36
- extend SingleForwardable
37
-
38
- def_instance_delegators :@struct, :[], :to_ptr
39
- def_single_delegators :ffi_struct, :ptr
40
-
41
- # the layout of the GObject struct
42
- module GObjectLayout
43
- def self.included base
44
- base.class_eval do
45
- layout :g_type_instance, :pointer,
46
- :ref_count, :uint,
47
- :qdata, :pointer
48
- end
49
- end
50
- end
51
-
52
- # the struct with unref ... manage object lifetime with this
53
- class ManagedStruct < FFI::ManagedStruct
54
- include GObjectLayout
55
-
56
- def self.release ptr
57
- # GLib::logger.debug("GObject::GObject::ManagedStruct.release") {
58
- # "unreffing #{ptr}"
59
- # }
60
- ::GObject::g_object_unref ptr
61
- end
12
+ # we have a number of things we need to inherit in different ways:
13
+ #
14
+ # - we want to be able to subclass GObject in Ruby in a simple way
15
+ # - the layouts of the nested structs need to inherit
16
+ # - we need to be able to cast between structs which share a base struct
17
+ # without creating new wrappers or messing up refcounting
18
+ # - we need automatic gobject refcounting
19
+ #
20
+ # the solution is to split the class into four areas which we treat
21
+ # differently:
22
+ #
23
+ # - we have a "wrapper" Ruby class to allow easy subclassing ... this has a
24
+ # @struct member which holds the actual pointer
25
+ # - we use "forwardable" to forward the various ffi methods on to the
26
+ # @struct member ... we arrange things so that subclasses do not need to
27
+ # do the forwarding themselves
28
+ # - we have two versions of the struct: a plain one which we can use for
29
+ # casting that will not change the refcounts
30
+ # - and a managed one with an unref which we just use for .new
31
+ # - we separate the struct layout into a separate module to avoid repeating
32
+ # ourselves
33
+
34
+ class GObject
35
+ extend Forwardable
36
+ extend SingleForwardable
37
+
38
+ def_instance_delegators :@struct, :[], :to_ptr
39
+ def_single_delegators :ffi_struct, :ptr
40
+
41
+ # the layout of the GObject struct
42
+ module GObjectLayout
43
+ def self.included base
44
+ base.class_eval do
45
+ layout :g_type_instance, :pointer,
46
+ :ref_count, :uint,
47
+ :qdata, :pointer
62
48
  end
49
+ end
50
+ end
63
51
 
64
- # the plain struct ... cast with this
65
- class Struct < FFI::Struct
66
- include GObjectLayout
67
-
68
- end
52
+ # the struct with unref ... manage object lifetime with this
53
+ class ManagedStruct < FFI::ManagedStruct
54
+ include GObjectLayout
69
55
 
70
- # don't allow ptr == nil, we never want to allocate a GObject struct
71
- # ourselves, we just want to wrap GLib-allocated GObjects
72
- #
73
- # here we use ManagedStruct, not Struct, since this is the ref that will
74
- # need the unref
75
- def initialize ptr
76
- # GLib::logger.debug("GObject::GObject.initialize") {"ptr = #{ptr}"}
77
- @struct = ffi_managed_struct.new ptr
78
- end
56
+ def self.release ptr
57
+ # GLib::logger.debug("GObject::GObject::ManagedStruct.release") {
58
+ # "unreffing #{ptr}"
59
+ # }
60
+ ::GObject::g_object_unref ptr
61
+ end
62
+ end
79
63
 
80
- # access to the casting struct for this class
81
- def ffi_struct
82
- self.class.ffi_struct
83
- end
64
+ # the plain struct ... cast with this
65
+ class Struct < FFI::Struct
66
+ include GObjectLayout
84
67
 
85
- class << self
86
- def ffi_struct
87
- self.const_get :Struct
88
- end
89
- end
68
+ end
90
69
 
91
- # access to the managed struct for this class
92
- def ffi_managed_struct
93
- self.class.ffi_managed_struct
94
- end
70
+ # don't allow ptr == nil, we never want to allocate a GObject struct
71
+ # ourselves, we just want to wrap GLib-allocated GObjects
72
+ #
73
+ # here we use ManagedStruct, not Struct, since this is the ref that will
74
+ # need the unref
75
+ def initialize ptr
76
+ # GLib::logger.debug("GObject::GObject.initialize") {"ptr = #{ptr}"}
77
+ @struct = ffi_managed_struct.new ptr
78
+ end
95
79
 
96
- class << self
97
- def ffi_managed_struct
98
- self.const_get :ManagedStruct
99
- end
100
- end
80
+ # access to the casting struct for this class
81
+ def ffi_struct
82
+ self.class.ffi_struct
83
+ end
101
84
 
85
+ class << self
86
+ def ffi_struct
87
+ self.const_get :Struct
88
+ end
102
89
  end
103
90
 
104
- class GParamSpec < FFI::Struct
105
- # the first few public fields
106
- layout :g_type_instance, :pointer,
107
- :name, :string,
108
- :flags, :uint,
109
- :value_type, :GType,
110
- :owner_type, :GType
91
+ # access to the managed struct for this class
92
+ def ffi_managed_struct
93
+ self.class.ffi_managed_struct
111
94
  end
112
95
 
113
- class GParamSpecPtr < FFI::Struct
114
- layout :value, GParamSpec.ptr
96
+ class << self
97
+ def ffi_managed_struct
98
+ self.const_get :ManagedStruct
99
+ end
115
100
  end
116
101
 
117
- attach_function :g_param_spec_get_blurb, [GParamSpec.ptr], :string
102
+ end
103
+
104
+ class GParamSpec < FFI::Struct
105
+ # the first few public fields
106
+ layout :g_type_instance, :pointer,
107
+ :name, :string,
108
+ :flags, :uint,
109
+ :value_type, :GType,
110
+ :owner_type, :GType
111
+ end
112
+
113
+ class GParamSpecPtr < FFI::Struct
114
+ layout :value, GParamSpec.ptr
115
+ end
116
+
117
+ attach_function :g_param_spec_get_blurb, [GParamSpec.ptr], :string
118
118
 
119
- attach_function :g_object_ref, [:pointer], :void
120
- attach_function :g_object_unref, [:pointer], :void
119
+ attach_function :g_object_ref, [:pointer], :void
120
+ attach_function :g_object_unref, [:pointer], :void
121
121
 
122
122
  end