Documentation ¶
Index ¶
- Constants
- func Compress(img *Image, params CompressParams) ([]byte, error)
- func Resize(src, dst *Image) error
- type CompressParams
- type ExifData
- type Flags
- type Image
- func Decompress(encoded []byte) (*Image, error)
- func FromImage(src image.Image, allowDeepClone bool) (*Image, error)
- func NewImage(width, height, nchan int) *Image
- func ResizeNew(src *Image, dstWidth, dstHeight int) *Image
- func UnrotateExif(exifOrientation int, src *Image) (*Image, error)
- func WrapImage(width, height, nchan int, pixels []byte) *Image
- func (img *Image) AvgColor() []uint8
- func (img *Image) Clone() *Image
- func (dst *Image) CopyImage(src *Image, dstX1, dstY1 int) error
- func (dst *Image) CopyImageRect(src *Image, srcX1, srcY1, srcX2, srcY2 int, dstX1, dstY1 int) error
- func (img *Image) ToImage() image.Image
- func (img *Image) ToRGB() *Image
- type PixelFormat
- type Sampling
Constants ¶
const (
ExifTagOrientation = 0x112 // Photo orientation
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CompressParams ¶
type CompressParams struct { PixelFormat PixelFormat Sampling Sampling Quality int // 1 .. 100 Flags Flags }
CompressParams are the TurboJPEG compression parameters
func MakeCompressParams ¶
func MakeCompressParams(pixelFormat PixelFormat, sampling Sampling, quality int, flags Flags) CompressParams
MakeCompressParams returns a fully populated CompressParams struct
type ExifData ¶ added in v1.0.1
type ExifData struct {
// contains filtered or unexported fields
}
ExifData is a wrapper around github.com/dsoprea/go-exif, with only the tags exposed that I've needed to manipulate
func LoadExif ¶ added in v1.0.1
Load a JPEG file, and parse it into it's JFIF segments. You can then read the existing EXIF data, or alter it. Note that if you modify the EXIF data, then reading that same data back from this data structure will not reflect your changes. You changes will only be reflected if you call Save(), and then reload that file using LoadJpegExif again.
func (*ExifData) GetOrientation ¶ added in v1.0.1
See https://www.impulseadventure.com/photo/exif-orientation.html 0th Row 0th Column 1 top left side 2 top right side 3 bottom right side 4 bottom left side 5 left side top 6 right side top 7 right side bottom 8 left side bottom
func (*ExifData) SetOrientation ¶ added in v1.0.4
Set photo orientation (See GetOrientation for meaning of the codes)
type Flags ¶
const ( FlagAccurateDCT Flags = C.TJFLAG_ACCURATEDCT FlagBottomUp Flags = C.TJFLAG_BOTTOMUP FlagFastDCT Flags = C.TJFLAG_FASTDCT FlagFastUpsample Flags = C.TJFLAG_FASTUPSAMPLE FlagNoRealloc Flags = C.TJFLAG_NOREALLOC FlagProgressive Flags = C.TJFLAG_PROGRESSIVE FlagStopOnWarning Flags = C.TJFLAG_STOPONWARNING )
type Image ¶
Image is the concrete image type that is used by all functions inside cimg.
func Decompress ¶
Decompress decompresses a JPEG image using TurboJPEG, or PNG image using Go's native PNG library The resulting image is RGB for JPEGs, or RGBA/Gray for PNG
func FromImage ¶
Convert a Go image.Image into a turbo.Image If allowDeepClone is true, and the source image is type GRAY, NRGBA, or RGBA, then the resulting Image points directly to the pixel buffer of the source image.
func UnrotateExif ¶ added in v1.0.3
UnrotateExif rewrites the bytes of an image so that the EXIF orientation information can be discarded. In other words, after running UnrotateExif, the encoded image orientation is the same as the natural display image orientation. exifOrientation must be either 3, 6, or 8.
func (*Image) AvgColor ¶ added in v1.0.5
AvgColor computes the average color of the entire image, per channel The averaging is performed in sRGB space (i.e. not physically correct) If the image has more than 8 channels, then the function will panic
func (*Image) CopyImage ¶ added in v1.0.7
CopyImage copies src into dst at the location dstX1, dstY1
func (*Image) CopyImageRect ¶ added in v1.0.7
CopyImageRect copies src into dst, at dstX1,dstY1. The source imagery is read from the rectangle specified by the 4 source location parameters. All coordinates are clipped prior to drawing. The only error condition is when the two images have a different number of channels
type PixelFormat ¶
const ( PixelFormatRGB PixelFormat = C.TJPF_RGB PixelFormatBGR PixelFormat = C.TJPF_BGR PixelFormatRGBX PixelFormat = C.TJPF_RGBX PixelFormatBGRX PixelFormat = C.TJPF_BGRX PixelFormatXBGR PixelFormat = C.TJPF_XBGR PixelFormatXRGB PixelFormat = C.TJPF_XRGB PixelFormatGRAY PixelFormat = C.TJPF_GRAY PixelFormatRGBA PixelFormat = C.TJPF_RGBA PixelFormatBGRA PixelFormat = C.TJPF_BGRA PixelFormatABGR PixelFormat = C.TJPF_ABGR PixelFormatARGB PixelFormat = C.TJPF_ARGB PixelFormatCMYK PixelFormat = C.TJPF_CMYK PixelFormatUNKNOWN PixelFormat = C.TJPF_UNKNOWN )
type Sampling ¶
const ( Sampling444 Sampling = C.TJSAMP_444 Sampling422 Sampling = C.TJSAMP_422 Sampling420 Sampling = C.TJSAMP_420 SamplingGray Sampling = C.TJSAMP_GRAY )