@@ -2,7 +2,7 @@ package bimg
22
33/*
44#cgo pkg-config: vips
5- #include "vips/vips .h"
5+ #include "vips.h"
66*/
77import "C"
88
@@ -139,6 +139,63 @@ const (
139139 ExtendLast Extend = C .VIPS_EXTEND_LAST
140140)
141141
142+ // BlendMode represents the blend mode used when compositing.
143+ // See: https://jcupitt.github.io/libvips/API/current/libvips-conversion.html#VipsBlendMode
144+ type BlendMode int
145+
146+ const (
147+ // BlendModeClear where the second object is drawn, the first is removed
148+ BlendModeClear BlendMode = C .VIPS_BLEND_MODE_CLEAR
149+ // BlendModeSource the second object is drawn as if nothing were below
150+ BlendModeSource BlendMode = C .VIPS_BLEND_MODE_SOURCE
151+ // BlendModeOver the image shows what you would expect if you held two semi-transparent slides on top of each other
152+ BlendModeOver BlendMode = C .VIPS_BLEND_MODE_OVER
153+ // BlendModeIn the first object is removed completely, the second is only drawn where the first was
154+ BlendModeIn BlendMode = C .VIPS_BLEND_MODE_IN
155+ // BlendModeOut the second is drawn only where the first isn't
156+ BlendModeOut BlendMode = C .VIPS_BLEND_MODE_OUT
157+ // BlendModeAtop this leaves the first object mostly intact, but mixes both objects in the overlapping area
158+ BlendModeAtop BlendMode = C .VIPS_BLEND_MODE_ATOP
159+ // BlendModeDest leaves the first object untouched, the second is discarded completely
160+ BlendModeDest BlendMode = C .VIPS_BLEND_MODE_DEST
161+ // BlendModeDestOver like OVER, but swaps the arguments
162+ BlendModeDestOver BlendMode = C .VIPS_BLEND_MODE_DEST_OVER
163+ // BlendModeDestIn like IN, but swaps the arguments
164+ BlendModeDestIn BlendMode = C .VIPS_BLEND_MODE_DEST_IN
165+ // BlendModeDestOut like OUT, but swaps the arguments
166+ BlendModeDestOut BlendMode = C .VIPS_BLEND_MODE_DEST_OUT
167+ // BlendModeDestAtop like ATOP, but swaps the arguments
168+ BlendModeDestAtop BlendMode = C .VIPS_BLEND_MODE_DEST_ATOP
169+ // BlendModeXOR something like a difference operator
170+ BlendModeXOR BlendMode = C .VIPS_BLEND_MODE_XOR
171+ // BlendModeAdd a bit like adding the two images
172+ BlendModeAdd BlendMode = C .VIPS_BLEND_MODE_ADD
173+ // BlendModeSaturate a bit like the darker of the two
174+ BlendModeSaturate BlendMode = C .VIPS_BLEND_MODE_SATURATE
175+ // BlendModeMultiply at least as dark as the darker of the two inputs
176+ BlendModeMultiply BlendMode = C .VIPS_BLEND_MODE_MULTIPLY
177+ // BlendModeScreen at least as light as the lighter of the inputs
178+ BlendModeScreen BlendMode = C .VIPS_BLEND_MODE_SCREEN
179+ // BlendModeOverlay multiplies or screens colors, depending on the lightness
180+ BlendModeOverlay BlendMode = C .VIPS_BLEND_MODE_OVERLAY
181+ // BlendModeDarken the darker of each component
182+ BlendModeDarken BlendMode = C .VIPS_BLEND_MODE_DARKEN
183+ // BlendModeLighten the lighter of each component
184+ BlendModeLighten BlendMode = C .VIPS_BLEND_MODE_LIGHTEN
185+ // BlendModeColorDodge brighten first by a factor second
186+ BlendModeColorDodge BlendMode = C .VIPS_BLEND_MODE_COLOUR_DODGE
187+ // BlendModeColorBurn darken first by a factor of second
188+ BlendModeColorBurn BlendMode = C .VIPS_BLEND_MODE_COLOUR_BURN
189+ // BlendModeHardLight multiply or screen, depending on lightness
190+ BlendModeHardLight BlendMode = C .VIPS_BLEND_MODE_HARD_LIGHT
191+ // BlendModeSoftLight darken or lighten, depending on lightness
192+ BlendModeSoftLight BlendMode = C .VIPS_BLEND_MODE_SOFT_LIGHT
193+ // BlendModeDifference difference of the two
194+ BlendModeDifference BlendMode = C .VIPS_BLEND_MODE_DIFFERENCE
195+ // BlendModeExclusion somewhat like DIFFERENCE, but lower-contrast
196+ BlendModeExclusion BlendMode = C .VIPS_BLEND_MODE_EXCLUSION
197+ )
198+
142199// WatermarkFont defines the default watermark font to be used.
143200var WatermarkFont = "sans 10"
144201
@@ -188,39 +245,42 @@ type Sharpen struct {
188245
189246// Options represents the supported image transformation options.
190247type Options struct {
191- Height int
192- Width int
193- AreaHeight int
194- AreaWidth int
195- Top int
196- Left int
197- Quality int
198- Compression int
199- Zoom int
200- Crop bool
201- SmartCrop bool // Deprecated, use: bimg.Options.Gravity = bimg.GravitySmart
202- Enlarge bool
203- Embed bool
204- Flip bool
205- Flop bool
206- Force bool
207- NoAutoRotate bool
208- NoProfile bool
209- Interlace bool
210- StripMetadata bool
211- Trim bool
212- Lossless bool
213- Extend Extend
214- Rotate Angle
215- Background Color
216- Gravity Gravity
217- Watermark Watermark
218- WatermarkImage WatermarkImage
219- Type ImageType
220- Interpolator Interpolator
221- Interpretation Interpretation
222- GaussianBlur GaussianBlur
223- Sharpen Sharpen
224- Threshold float64
225- OutputICC string
248+ Height int
249+ Width int
250+ AreaHeight int
251+ AreaWidth int
252+ Top int
253+ Left int
254+ Quality int
255+ Compression int
256+ Zoom int
257+ Crop bool
258+ SmartCrop bool // Deprecated, use: bimg.Options.Gravity = bimg.GravitySmart
259+ Enlarge bool
260+ Embed bool
261+ Flip bool
262+ Flop bool
263+ Force bool
264+ NoAutoRotate bool
265+ NoProfile bool
266+ Interlace bool
267+ StripMetadata bool
268+ Trim bool
269+ Lossless bool
270+ Composite bool
271+ Extend Extend
272+ Rotate Angle
273+ Background Color
274+ Gravity Gravity
275+ Watermark Watermark
276+ WatermarkImage WatermarkImage
277+ Type ImageType
278+ Interpolator Interpolator
279+ Interpretation Interpretation
280+ GaussianBlur GaussianBlur
281+ Sharpen Sharpen
282+ BlendMode BlendMode
283+ Threshold float64
284+ OutputICC string
285+ CompositeLayers []* Image
226286}
0 commit comments