service

package
v0.0.0-...-67d91c4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2022 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const EXIF_GPSINFO_TAG = 0x8825 // GPSInfo
View Source
const EXIF_HEADER_READ_SIZE = 12
View Source
const EXIF_IOP_TAG = 0xa005 // ExifInteroperabilityOffset
View Source
const EXIF_SUBIFD_OFFSET_TAG = 0x8769 // SubIFD

Variables

View Source
var EXIF_GPSINFO_TAGS = map[uint16]string{
	0x0000: "GPSVersionID",
	0x0001: "GPSLatitudeRef",
	0x0002: "GPSLatitude",
	0x0003: "GPSLongitudeRef",
	0x0004: "GPSLongitude",
	0x0005: "GPSAltitudeRef",
	0x0006: "GPSAltitude",
	0x0007: "GPSTimeStamp",
	0x0008: "GPSSatellites",
	0x0009: "GPSStatus",
	0x000a: "GPSMeasureMode",
	0x000b: "GPSDOP",
	0x000c: "GPSSpeedRef",
	0x000d: "GPSSpeed",
	0x000e: "GPSTrackRef",
	0x000f: "GPSTrack",
	0x0010: "GPSImgDirectionRef",
	0x0011: "GPSImgDirection",
	0x0012: "GPSMapDatum",
	0x0013: "GPSDestLatitudeRef",
	0x0014: "GPSDestLatitude",
	0x0015: "GPSDestLongitudeRef",
	0x0016: "GPSDestLongitude",
	0x0017: "GPSDestBearingRef",
	0x0018: "GPSDestBearing",
	0x0019: "GPSDestDistanceRef",
	0x001a: "GPSDestDistance",
	0x001b: "GPSProcessingMethod",
	0x001c: "GPSAreaInformation",
	0x001d: "GPSDateStamp",
	0x001e: "GPSDifferential",
}
View Source
var EXIF_HEADER_SIGNATURE = []byte{0xff, 0xd8, 0xff, 0xe1}
View Source
var EXIF_IOP_TAGS = map[uint16]string{
	0x0001: "InteroperabilityIndex",
	0x0002: "InteroperabilityVersion",
	0x1000: "RelatedImageFileFormat",
	0x1001: "RelatedImageWidth",
	0x1002: "RelatedImageLength",
}
View Source
var EXIF_TAGS = map[uint16]string{
	0x0100: "ImageWidth",
	0x0101: "ImageLength",
	0x0102: "BitsPerSample",
	0x0103: "Compression",
	0x0106: "PhotometricInterpretation",
	0x0111: "StripOffsets",
	0x0115: "SamplesPerPixel",
	0x0116: "RowsPerStrip",
	0x0117: "StripByteConunts",
	0x010e: "ImageDescription",
	0x010f: "Make",
	0x0110: "Model",
	0x0112: "Orientation",
	0x011a: "XResolution",
	0x011b: "YResolution",
	0x011c: "PlanarConfiguration",
	0x0128: "ResolutionUnit",
	0x0131: "Software",
	0x0132: "DateTime",
	0x013e: "WhitePoint",
	0x013f: "PrimaryChromaticities",
	0x0201: "JpegIFOffset",
	0x0202: "JpegIFByteCount",
	0x0211: "YCbCrCoefficients",
	0x0213: "YCbCrPositioning",
	0x0214: "ReferenceBlackWhite",
	0x8298: "Copyright",
	0x8769: "ExifOffset",

	0x829a: "ExposureTime",
	0x829d: "FNumber",
	0x8822: "ExposureProgram",
	0x8827: "ISOSpeedRatings",
	0x9000: "ExifVersion",
	0x9003: "DateTimeOriginal",
	0x9004: "DateTimeDigitized",
	0x9101: "ComponentConfiguration",
	0x9102: "CompressedBitsPerPixel",
	0x9201: "ShutterSpeedValue",
	0x9202: "ApertureValue",
	0x9203: "BrightnessValue",
	0x9204: "ExposureBiasValue",
	0x9205: "MaxApertureValue",
	0x9206: "SubjectDistance",
	0x9207: "MeteringMode",
	0x9208: "LightSource",
	0x9209: "Flash",
	0x920a: "FocalLength",
	0x927c: "MakerNote",
	0x9286: "UserComment",
	0xa000: "FlashPixVersion",
	0xa001: "ColorSpace",
	0xa002: "ExifImageWidth",
	0xa003: "ExifImageHeight",
	0xa004: "RelatedSoundFile",
	0xa005: "ExifInteroperabilityOffset",
	0xa20e: "FocalPlaneXResolution",
	0xa20f: "FocalPlaneYResolution",
	0xa210: "FocalPlaneResolutionUnit",
	0xa217: "SensingMethod",
	0xa300: "FileSource",
	0xa301: "SceneType",
	0xa401: "CustomRendered",
	0xa402: "ExposureMode",
	0xa403: "WhiteBalance",
	0xa404: "DigitalZoomRatio",
	0xa405: "FocalLengthIn35mmFilm",
	0xa406: "SceneCaptureType",
	0xa407: "GainControl",
	0xa408: "Contrast",
	0xa409: "Saturation",
	0xa40a: "Sharpness",
	0xa40b: "DeviceSettingDescription",
	0xa40c: "SubjectDistanceRange",
	0xa420: "ImageUniqueID",
	0xa430: "CameraOwnerName",
	0xa431: "BodySerialNumber",
	0xa432: "LensSpecification",
	0xa433: "LensMake",
	0xa434: "LensModel",
	0xa435: "LensSerialNumber",
}
View Source
var FormatType = map[int]string{
	1:  "UB",
	2:  "A",
	3:  "US",
	4:  "UL",
	5:  "UR",
	6:  "SB",
	7:  "?",
	8:  "SS",
	9:  "SL",
	10: "SR",
}
View Source
var IfdSeqMap = map[uint8]string{
	0: "Main",
	1: "Thumbnail",
	2: "SubIFD",
	3: "GPSInfo",
	4: "IOPInfo",
}

Functions

func Barcode

func Barcode(value string) ([]byte, error)

生成条形码

func ClipperRectangle

func ClipperRectangle(file multipart.File, x1, y1, x2, y2 int) (outByte []byte, err error)

func ClipperRound

func ClipperRound(file multipart.File, x, y, r int) (outByte []byte, err error)

TODO BUG

func CompositeGif

func CompositeGif(file []*multipart.FileHeader) (outByte []byte, err error)

func FontTTFInit

func FontTTFInit()

func ImageResize

func ImageResize(src image.Image, w, h int) image.Image

func Img2Txt

func Img2Txt(file multipart.File) (outByte []byte, err error)

func ImgAlpha

func ImgAlpha(file multipart.File, percentage float64) (outByte []byte, err error)

func ImgCenter

func ImgCenter(file multipart.File) (outByte []byte, err error)

func ImgCompress

func ImgCompress(img image.Image, width, height int, outType string) []byte

// Nearest-neighbor interpolation

NearestNeighbor InterpolationFunction = iota
// Bilinear interpolation
Bilinear
// Bicubic interpolation (with cubic hermite spline)
Bicubic
// Mitchell-Netravali interpolation
MitchellNetravali
// Lanczos interpolation (a=2)
Lanczos2
// Lanczos interpolation (a=3)
Lanczos3

func ImgGray

func ImgGray(file multipart.File) (outByte []byte, err error)

func ImgInvert

func ImgInvert(file multipart.File) (outByte []byte, err error)

func ImgStitching

func ImgStitching(fileList []multipart.File) (outByte []byte, err error)

选用最大图片的宽度, 垂直依次拼接

func ImgStitchingParallel

func ImgStitchingParallel()

TODO 选用最小图片高度, 水平依次拼接

func ImgStitchingSudoku

func ImgStitchingSudoku(fileList []multipart.File) (outByte []byte, err error)

选用最大图片宽高, 九宫格拼接

func PrintIFD

func PrintIFD(ifds []IfdEntries)

PrintIfd prints the supplied IFD entries

func QRCodeRecognition

func QRCodeRecognition()

识别二维码 TODO github.com/tuotoo/qrcode 三方库有问题

func QrCodeBase64

func QrCodeBase64(value string) ([]byte, error)

生成二维码

func Revolve

func Revolve(file multipart.File, revolveType string) (outByte []byte, err error)

旋转90度

func Txt2Img

func Txt2Img(txt string, fontSize, dpi, spacing int, outType string) (outByte []byte, err error)

outType png, jpg; 默认png

func WatermarkLogo(imgFile, logoFile multipart.File) (outByte []byte, err error)

func WatermarkTxt

func WatermarkTxt(file multipart.File, txt, color string, fontSize, dpi, position int) (outByte []byte, err error)

position 1:左下角, 2:居中, 3:左上角, 4:右上角, 5:右下角

Types

type ExifData

type ExifData struct {
	IfdData map[string][]IfdEntries
	// contains filtered or unexported fields
}

ExifData represents a map of IfdEntries

func NewExifData

func NewExifData() *ExifData

func (*ExifData) GetExifData

func (ex *ExifData) GetExifData(r io.Reader) (data []byte, err error)

GetExifData checks the byte stream header to match EXIF metadata and returns the EXIF data up to length defined in the header

func (*ExifData) GetTagValues

func (ex *ExifData) GetTagValues(tag uint16) (values interface{}, ok bool)

func (*ExifData) ProcessExifStream

func (ex *ExifData) ProcessExifStream(f multipart.File) (err error)

ProcessExifStream reads the image file content

type ExifInterface

type ExifInterface interface {
	GetExifHeader(r io.Reader) (data []byte, err error)
	ProcessExifStream(f *os.File) (err error)
	GetTagValues(tag uint16) (values interface{}, ok bool)
}

ExifInterface implements Exif Header retrieval and Exif stream processing

type IfdEntries

type IfdEntries struct {
	IfdSeq  uint8
	Tag     uint16
	TagDesc string
	Format  uint16
	Values  interface{}
}

IfdEntries represents EXIF metadata for specific tag

type TiffData

type TiffData struct {
	// contains filtered or unexported fields
}

TiffData contains the byteorder, data buffer and current slice

func (TiffData) GetFirstIFD

func (ex TiffData) GetFirstIFD() uint32

GetFirstIFD returns the first IFD in the data

func (TiffData) GetIFDList

func (ex TiffData) GetIFDList() []uint32

GetIFDList returns the list of all IFDs (as offsets)

func (TiffData) GetNextIFD

func (ex TiffData) GetNextIFD(ifdOffset uint32) uint32

GetNextIFD calculates end returns offset of the next available IFD

func (*TiffData) Int16

func (ex *TiffData) Int16() int16

Int16 returns 16 bit signed integer taking into consideration the endianness defined

func (*TiffData) Int32

func (ex *TiffData) Int32() int32

Int32 returns 32 bit signed integer taking into consideration the endianness defined

func (*TiffData) Int64

func (ex *TiffData) Int64() int64

Int64 returns 64 bit signed integer taking into consideration the endianness defined

func (TiffData) ProcessIFD

func (ex TiffData) ProcessIFD(ifdSeq uint8, ifdOffset uint32, tagDict map[uint16]string) []IfdEntries

ProcessIFD takes the IFD sequence; IFD offset; EXIF tags dictionary and returns an array of IfdEntries

func (*TiffData) SetByteOrder

func (ex *TiffData) SetByteOrder(byteorder string)

SetByteOrder sets the byte order for the TiffData (Intel/Motorola)

func (*TiffData) SetData

func (ex *TiffData) SetData(data []byte)

SetData sets the EXIF data in TiffData struct

func (*TiffData) Slice

func (ex *TiffData) Slice(offset uint32, length uint32) *TiffData

Slice allocates and sets TiffData.slice bases on provided offset & length returns pointer to TiffData

func (*TiffData) Uint16

func (ex *TiffData) Uint16() uint16

Uint16 returns 16 bit unsigned integer taking into consideration the endianness defined

func (*TiffData) Uint32

func (ex *TiffData) Uint32() uint32

Uint32 returns 32 bit unsigned integer taking into consideration the endianness defined

func (*TiffData) Uint64

func (ex *TiffData) Uint64() uint64

Uint64 returns 64 bit unsigned integer taking into consideration the endianness defined

type TiffInterface

type TiffInterface interface {
	SetByteOrder(byteorder string)
	SetData(data []byte)
	GetFirstIFD() uint32
	GetNextIFD(ifdOffset uint32) uint32
	GetIFDList() []uint32
	ProcessIFD(ifdSeq uint8, ifdOffset uint32, tagDict map[uint16]string) []IfdEntries
}

TiffInterface implements methods to process IFDs

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL