forked from tidbyt/go-libwebp
/
webp.go
77 lines (63 loc) · 2.26 KB
/
webp.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// Package webp provides an interface to libwebp library to decoding/encoding
// WebP image.
package webp
/*
#cgo CFLAGS: -I./../libwebp/src/
#cgo CFLAGS: -Wno-pointer-sign -DWEBP_USE_THREAD
#cgo !windows LDFLAGS: -lm
#include <stdlib.h>
#include <webp/encode.h>
*/
import "C"
import _ "github.com/Dadido3/go-libwebp/webp/wrapper"
// ColorSpace represents encoding color space in WebP
type ColorSpace int
const (
// YUV420 specifies YUV4:2:0
YUV420 ColorSpace = C.WEBP_YUV420
// YUV420A specifies YUV4:2:0 with alpha channel
YUV420A ColorSpace = C.WEBP_YUV420A
)
// ImageHint corresponds to C.WebPImageHint.
type ImageHint int
const (
HintDefault ImageHint = C.WEBP_HINT_DEFAULT
HintPicture ImageHint = C.WEBP_HINT_PICTURE
HintPhoto ImageHint = C.WEBP_HINT_PHOTO
HintGraph ImageHint = C.WEBP_HINT_GRAPH
HintLast ImageHint = C.WEBP_HINT_LAST
)
// Preset corresponds to C.WebPPreset.
type Preset int
const (
// PresetDefault corresponds to WEBP_PRESET_DEFAULT, for default preset.
PresetDefault Preset = C.WEBP_PRESET_DEFAULT
// PresetPicture corresponds to WEBP_PRESET_PICTURE, for digital picture, like portrait, inner shot
PresetPicture Preset = C.WEBP_PRESET_PICTURE
// PresetPhoto corresponds to WEBP_PRESET_PHOTO, for outdoor photograph, with natural lighting
PresetPhoto Preset = C.WEBP_PRESET_PHOTO
// PresetDrawing corresponds to WEBP_PRESET_DRAWING, for hand or line drawing, with high-contrast details
PresetDrawing Preset = C.WEBP_PRESET_DRAWING
// PresetIcon corresponds to WEBP_PRESET_ICON, for small-sized colorful images
PresetIcon Preset = C.WEBP_PRESET_ICON
// PresetText corresponds to WEBP_PRESET_TEXT, for text-like
PresetText Preset = C.WEBP_PRESET_TEXT
)
// FilterType corresponds to filter types in compression parameters.
type FilterType int
const (
// SimpleFilter (=0, default)
SimpleFilter FilterType = iota
// StrongFilter (=1)
StrongFilter
)
// Preprocessing corresponds to preprocessing filter parameter.
type Preprocessing int
const (
// PreprocessingNone specifies to disable preprocessing filter.
PreprocessingNone = 0
// PreprocessingSegmentSmooth specifies segment-smooth filter.
PreprocessingSegmentSmooth = 1
//PreprocessingPseudoRandomDithering specifies pseudo-random dithering filter.
PreprocessingPseudoRandomDithering = 2
)