Documentation ¶
Index ¶
- Constants
- Variables
- func Backend() string
- func QuantumDepth() uint
- func QuantumRange() uint64
- func SupportedFormats() ([]string, error)
- type AffineMatrix
- type Channel
- type ChannelStatistics
- type Colorspace
- type Composite
- type CropStrategy
- type ErrorStats
- type Filter
- type FloatMatrix
- func (m FloatMatrix) Columns() int
- func (m FloatMatrix) Multiply(n FloatMatrix) (FloatMatrix, error)
- func (m FloatMatrix) Rows() int
- func (m FloatMatrix) SubMatrix(x int, y int, rows int, columns int) (FloatMatrix, error)
- func (m FloatMatrix) Transposed() FloatMatrix
- func (m FloatMatrix) UnrollX() []float64
- func (m FloatMatrix) UnrollY() []float64
- type Frame
- type Histogram
- type HistogramItem
- type Image
- func (im *Image) AddBorder(r Rect, c *Pixel) (*Image, error)
- func (im *Image) AddFrame(f Frame, c *Pixel) (*Image, error)
- func (im *Image) AffineTransform(m *AffineMatrix) (*Image, error)
- func (im *Image) Append(image *Image) error
- func (im *Image) Apply(f func(*Image) (*Image, error)) (*Image, error)
- func (im *Image) ApplyDataFunc(f C.ImageDataFunc, data interface{}) (*Image, error)
- func (im *Image) ApplyFunc(f C.ImageFunc) (*Image, error)
- func (im *Image) ApplyRectFunc(f C.ImageDataFunc, r Rect) (*Image, error)
- func (im *Image) AverageColor() (*Pixel, error)
- func (im *Image) BackgroundColor() *Pixel
- func (im *Image) BorderColor() *Pixel
- func (im *Image) ChannelDepth(ch Channel) (uint, error)
- func (im *Image) ChannelImage(ch Channel) (*Image, error)
- func (im *Image) Chop(r Rect) (*Image, error)
- func (im *Image) Clone() (*Image, error)
- func (im *Image) Coalesce() (*Image, error)
- func (im *Image) Colorspace() Colorspace
- func (im *Image) Compare(src *Image) (*ErrorStats, error)
- func (im *Image) Composite(c Composite, draw *Image, x int, y int) error
- func (im *Image) CompositeInto(c Composite, canvas *Image, x int, y int) error
- func (im *Image) Convolve(order int, kernel []float64) (*Image, error)
- func (im *Image) Crop(r Rect) (*Image, error)
- func (im *Image) CropResize(width, height int, filter Filter, cs CropStrategy) (*Image, error)
- func (im *Image) CropToRatio(ratio float64, cs CropStrategy) (*Image, error)
- func (im *Image) Deconstruct() (*Image, error)
- func (im *Image) Delay() int
- func (im *Image) Depth() int
- func (im *Image) DestroyProperties()
- func (im *Image) Dispose()
- func (im *Image) Duration() int
- func (im *Image) Encode(w io.Writer, info *Info) error
- func (im *Image) Entropy() float32
- func (im *Image) EntropyRect(r Rect) float32
- func (im *Image) Extent(r Rect) (*Image, error)
- func (im *Image) First() *Image
- func (im *Image) Flatten() (*Image, error)
- func (im *Image) Flip() (*Image, error)
- func (im *Image) FloatMatrix() (FloatMatrix, error)
- func (im *Image) Flop() (*Image, error)
- func (im *Image) Format() string
- func (im *Image) Frame(idx int) (*Image, error)
- func (im *Image) FrameIndex() int
- func (im *Image) Func(f C.ImageFunc) (*Image, error)
- func (im *Image) GifEncode() ([]byte, error)
- func (im *Image) GoImage() (image.Image, error)
- func (im *Image) HasProperty(key string) bool
- func (im *Image) Height() int
- func (im *Image) Histogram() (*Histogram, error)
- func (im *Image) Image() *C.Image
- func (im *Image) ImportChannel(src *Image, ch Channel) error
- func (im *Image) IsEqual(src *Image) (bool, error)
- func (im *Image) IsOrphan() bool
- func (im *Image) IsPalette() (bool, error)
- func (im *Image) Last() *Image
- func (im *Image) Magnify() (*Image, error)
- func (im *Image) MatteColor() *Pixel
- func (im *Image) Minify() (*Image, error)
- func (im *Image) Mosaic() (*Image, error)
- func (im *Image) NColors() (int, error)
- func (im *Image) NFrames() int
- func (im *Image) Next() *Image
- func (im *Image) Operate(op Operator, value float64) error
- func (im *Image) OperateChannel(op Operator, ch Channel, value float64) error
- func (im *Image) PHash() (PHash, error)
- func (im *Image) Pixel(x int, y int) (*Pixel, error)
- func (im *Image) Pixels(r Rect) ([]*Pixel, error)
- func (im *Image) Prepend(image *Image) error
- func (im *Image) Prev() *Image
- func (im *Image) Properties() []string
- func (im *Image) Property(key string) string
- func (im *Image) Raise(r Rect, threedimensional bool) (*Image, error)
- func (im *Image) Rect() Rect
- func (im *Image) Remove() bool
- func (im *Image) RemoveFirst() bool
- func (im *Image) RemoveIndex(idx int) bool
- func (im *Image) RemoveLast() bool
- func (im *Image) RemoveProperty(key string) bool
- func (im *Image) Resize(width, height int, filter Filter) (*Image, error)
- func (im *Image) ResizeBlur(width, height int, filter Filter, blur float64) (*Image, error)
- func (im *Image) Reverse()
- func (im *Image) Roll(xoffset, yoffset int) (*Image, error)
- func (im *Image) Sample(width, height int) (*Image, error)
- func (im *Image) Scale(width, height int) (*Image, error)
- func (im *Image) SetBackgroundColor(px *Pixel)
- func (im *Image) SetBorderColor(px *Pixel)
- func (im *Image) SetChannelDepth(ch Channel, depth uint) error
- func (im *Image) SetColorspace(cs Colorspace)
- func (im *Image) SetMatteColor(px *Pixel)
- func (im *Image) SetPixel(x int, y int, p *Pixel) error
- func (im *Image) SetPixels(r Rect, p []*Pixel) error
- func (im *Image) SetProperty(key string, value string) bool
- func (im *Image) Shave(r Rect) (*Image, error)
- func (im *Image) Signature() string
- func (im *Image) Statistics() (*Statistics, error)
- func (im *Image) Thumbnail(width, height int) (*Image, error)
- func (im *Image) ToChannelImage(ch Channel) error
- func (im *Image) ToColorspace(cs Colorspace) error
- func (im *Image) Transform(crop, image string) *Image
- func (im *Image) TransformColorspace(cs Colorspace) (*Image, error)
- func (im *Image) Width() int
- type Info
- type Operator
- type Optimizer
- type PHash
- type Pixel
- type Rect
- type Statistics
- type Storage
Constants ¶
const ( CharPixel Storage = C.CharPixel ShortPixel = C.ShortPixel IntegerPixel = C.IntegerPixel LongPixel = C.LongPixel FloatPixel = C.FloatPixel DoublePixel = C.DoublePixel )
Variables ¶
var ( ErrNoSuchFrame = errors.New("no such frame") ErrNoData = errors.New("no image data") )
Functions ¶
func Backend ¶
func Backend() string
Backend returns the name of the library backend which was selected at build time. It must be either "ImageMagick" or "GraphicsMagick".
func QuantumDepth ¶
func QuantumDepth() uint
QuantumDepth returns the color depth used in magick. This value is selected when compiling ImageMagick or GraphicsMagick and it's usually 8.
func QuantumRange ¶
func QuantumRange() uint64
QuantumRange returns the maximum value representable by the current QuantumDepth (= pow(2, QuantumDepth) - 1).
func SupportedFormats ¶
Supported formats returns a list with the names of all supported image formats. This varies depending on the backend and the compile options that have been used while building IM or GM.
Types ¶
type AffineMatrix ¶
type AffineMatrix struct {
Sx, Sy, Rx, Ry, Tx, Ty float64
}
type Channel ¶
type Channel C.ChannelType
const ( CRed Channel = C.RedChannel /* RGB Red channel */ CCyan Channel = C.CyanChannel /* CMYK Cyan channel */ CGreen Channel = C.GreenChannel /* RGB Green channel */ CMagenta Channel = C.MagentaChannel /* CMYK Magenta channel */ CBlue Channel = C.BlueChannel /* RGB Blue channel */ CYellow Channel = C.YellowChannel /* CMYK Yellow channel */ COpacity Channel = C.OpacityChannel /* Opacity channel */ CBlack Channel = C.BlackChannel /* CMYK Black (K) channel */ CAll Channel = C.AllChannels /* Color channels */ CGray Channel = C.GrayChannel /* Color channels represent an intensity. */ )
type ChannelStatistics ¶
type ChannelStatistics struct { Minimum float64 Maximum float64 Mean float64 StdDev float64 Variance float64 // The following fields are only filled in when building // against ImageMagick Kurtosis float64 Skewness float64 }
ChannelStatistics includes several statistics about a color channel. Magick normalizes all fields in this structure to the interval [0, 1].
type Colorspace ¶
type Colorspace C.ColorspaceType
When encoding an output image, the colorspaces RGB, CMYK, and GRAY may be specified. The CMYK option is only applicable when writing TIFF, JPEG, and Adobe Photoshop bitmap (PSD) files.
const ( RGB Colorspace = C.RGBColorspace // Red, Green, Blue colorspace. GRAY Colorspace = C.GRAYColorspace // Similar to Luma (Y) according to ITU-R 601 TRANSPARENT Colorspace = C.TransparentColorspace // RGB which preserves the matte while quantizing colors. OHTA Colorspace = C.OHTAColorspace XYZ Colorspace = C.XYZColorspace // CIE XYZ YCC Colorspace = C.YCCColorspace // Kodak PhotoCD PhotoYCC YIQ Colorspace = C.YIQColorspace YPBPR Colorspace = C.YPbPrColorspace YUV Colorspace = C.YUVColorspace // YUV colorspace as used for computer video. CMYK Colorspace = C.CMYKColorspace // Cyan, Magenta, Yellow, Black colorspace. SRGB Colorspace = C.sRGBColorspace // Kodak PhotoCD sRGB HSL Colorspace = C.HSLColorspace // Hue, saturation, luminosity HWB Colorspace = C.HWBColorspace // Hue, whiteness, blackness LAB Colorspace = C.LABColorspace // ITU LAB REC_601_LUMA Colorspace = C.Rec601LumaColorspace // Luma (Y) according to ITU-R 601 REC_601_YCBCR Colorspace = C.Rec601YCbCrColorspace // YCbCr according to ITU-R 601 REC_709_LUMA Colorspace = C.Rec709LumaColorspace // Luma (Y) according to ITU-R 709 REC_709_YCBCR Colorspace = C.Rec709YCbCrColorspace // YCbCr according to ITU-R 709 )
func (Colorspace) String ¶
func (c Colorspace) String() string
type Composite ¶
type Composite int
Composite represents a composition operation. Refer to the individual constants for more information. Note that not all compositions are supported by the GraphicsMagick backend.
const ( CompositeAlpha Composite = iota + 1 CompositeAtop CompositeBlend CompositeBlur CompositeBumpmap CompositeChangeMask CompositeClear CompositeColorBurn CompositeColorDodge CompositeColorize CompositeCopyBlack CompositeCopyBlue CompositeCopy CompositeCopyCyan CompositeCopyGreen CompositeCopyMagenta CompositeCopyAlpha CompositeCopyRed CompositeCopyYellow CompositeDarken CompositeDarkenIntensity CompositeDifference CompositeDisplace CompositeDissolve CompositeDistort CompositeDivideDst CompositeDivideSrc CompositeDstAtop CompositeDst CompositeDstIn CompositeDstOut CompositeDstOver CompositeExclusion CompositeHardLight CompositeHue CompositeIn CompositeIntensity CompositeLighten CompositeLightenIntensity CompositeLinearBurn CompositeLinearDodge CompositeLinearLight CompositeLuminize CompositeMathematics CompositeMinusDst CompositeMinusSrc CompositeModulate CompositeModulusAdd CompositeModulusSubtract CompositeMultiply CompositeNo CompositeOut CompositeOver CompositeOverlay CompositePegtopLight CompositePinLight CompositePlus CompositeReplace CompositeSaturate CompositeScreen CompositeSoftLight CompositeSrcAtop CompositeSrc CompositeSrcIn CompositeSrcOut CompositeSrcOver CompositeThreshold CompositeUndefined CompositeVividLight CompositeXor )
type CropStrategy ¶
type CropStrategy int
CropStrategy defines the strategy used to crop an image to a given ratio.
const ( // When cropping to a given aspect ratio, discard content // from the edges of the image and keep the content at the center. CSCenter CropStrategy = iota // When cropping to a given aspect ratio, grab the section of the // image with higher entropy. This is useful when you want to crop // the image to a given ratio and end up with the most 'meaningful' // part of the image. CSMaxEntropy )
type ErrorStats ¶
ErrorStats represents the difference between two compared images.
func (*ErrorStats) IsZero ¶
func (stats *ErrorStats) IsZero() bool
IsZero returns true iff the two compared images are equal.
type Filter ¶
type Filter C.FilterTypes
const ( FPoint Filter = C.PointFilter FBox Filter = C.BoxFilter FTriangle Filter = C.TriangleFilter FHermite Filter = C.HermiteFilter FHanning Filter = C.HanningFilter FHamming Filter = C.HammingFilter FBlackman Filter = C.BlackmanFilter FGaussian Filter = C.GaussianFilter FQuadratic Filter = C.QuadraticFilter FCubic Filter = C.CubicFilter FCatrom Filter = C.CatromFilter FMitchell Filter = C.MitchellFilter FLanczos Filter = C.LanczosFilter FBessel Filter = C.BesselFilter FSinc Filter = C.SincFilter )
type FloatMatrix ¶
type FloatMatrix [][]float64
func NewDCTMatrix ¶
func NewDCTMatrix(order int) FloatMatrix
func NewFloatMatrix ¶
func NewFloatMatrix(rows int, columns int) FloatMatrix
func (FloatMatrix) Columns ¶
func (m FloatMatrix) Columns() int
func (FloatMatrix) Multiply ¶
func (m FloatMatrix) Multiply(n FloatMatrix) (FloatMatrix, error)
func (FloatMatrix) Rows ¶
func (m FloatMatrix) Rows() int
func (FloatMatrix) SubMatrix ¶
func (m FloatMatrix) SubMatrix(x int, y int, rows int, columns int) (FloatMatrix, error)
func (FloatMatrix) Transposed ¶
func (m FloatMatrix) Transposed() FloatMatrix
func (FloatMatrix) UnrollX ¶
func (m FloatMatrix) UnrollX() []float64
UnrollX returns all values in a slice which contains all rows in increasing order.
func (FloatMatrix) UnrollY ¶
func (m FloatMatrix) UnrollY() []float64
UnrollX returns all values in a slice which contains all columns in increasing order.
type Histogram ¶
type Histogram struct {
Items []*HistogramItem
}
type HistogramItem ¶
type Image ¶
type Image struct {
// contains filtered or unexported fields
}
Image represents an in-memory decoded image. Some images (like e.g. GIF animations) might have multiple frames. Unless indicated otherwise, functions work in the same way with both single a multi-frame images, performing coalescing when needed. To operate on a single frame use e.g. im.Frame(i).Resize() instead of im.Resize(). Frames might be added or removed with list related functions, like Append() or Remove().
func Constitute ¶
Constitute returns a new image from in-memory data. channels must be a string formed or the following characters, each one representing a channel, in order.
R = red G = green B = blue A = alpha (same as Transparency) O = Opacity T = Transparency C = cyan Y = yellow M = magenta K = black I = intensity (for grayscale) P = pad, to skip over a chnnel which is intentionally ignored
Creation of an alpha channel for CMYK images is currently not supported. Note that pixels must be either empty, resulting in an image with all pixels the zero values, or have the appropiate size for the image dimensions, the number of channels and the storage type.
func Decode ¶
Decode tries to decode an image from the given io.Reader. If the image can't be decoded or it's corrupt, an error will be returned. Depending on the backend and compile time options, the number of supported formats might vary. Use SupportedFormats() to list the all.
func DecodeData ¶
DecodeData works like Decode, but accepts a []byte rather than an io.Reader.
func DecodeFile ¶
DecodeFile works like Decode, but accepts a filename.
func New ¶
New returns a new RGBA image with the given size. If you need more granularity, see Constitute.
func (*Image) AffineTransform ¶
func (im *Image) AffineTransform(m *AffineMatrix) (*Image, error)
AffineTransform returns a new image created by transforming the original image as dictated by the affine matrix.
func (*Image) ApplyDataFunc ¶
func (im *Image) ApplyDataFunc(f C.ImageDataFunc, data interface{}) (*Image, error)
ApplyDataFunc calls the given C.ImageDataFunc with the data argument (which must be a pointer) for all the frames in the given image and returns the results. The given function only needs to work on individual images. ApplyDataFunc will coalesce the original image and create a new sequence of images if required.
func (*Image) ApplyFunc ¶
ApplyFunc calls the given C.ImageFunc for all the frames in the given image and returns the results. The given function only needs to work on individual images. ApplyFunc will coalesce the original image and create a new sequence of images if required.
func (*Image) ApplyRectFunc ¶
ApplyRectFunc calls the given C.ImageDataFunc with Rect argument converted to a *C.RectangleInfo for all the frames in the given image and returns the results. The given function only needs to work on individual images. ApplyRectFunc will coalesce the original image and create a new sequence of images if required.
func (*Image) AverageColor ¶
AverageColor returns the image's average color as a *Pixel.
func (*Image) BackgroundColor ¶
BackgroundColor returns the image background color.
func (*Image) BorderColor ¶
BorderColore returns the image border color.
func (*Image) ChannelDepth ¶
ChannelDepth returns the depth of the given channel.
func (*Image) ChannelImage ¶
ChannelImage returns a new image with all the channels equal to the given channel. e.g. on an image with all pixels with red = 255, im.ChannelImage(magick.CRed) will result in a white image, since green and blue will be set to the red value. See also ToChannelImage.
func (*Image) Clone ¶
Clone returns a copy of the image. If the image has multiple frames, it copies all of them. To Clone just one frame use im.Frame(i).Clone().
func (*Image) Coalesce ¶
Coalesce composites a set of images while respecting any page offsets and disposal methods. GIF, MIFF, and MNG animation sequences typically start with an image background and each subsequent image varies in size and offset. Coalesce() returns a new sequence where each image in the sequence is the same size as the first and composited with the next image in the sequence.
func (*Image) Colorspace ¶
func (im *Image) Colorspace() Colorspace
Colorspace returns the image colorspace.
func (*Image) Compare ¶
func (im *Image) Compare(src *Image) (*ErrorStats, error)
Compare returns comparison of two images as an ErrorStatus. See also IsEqual.
func (*Image) Composite ¶
Composite modifies the image, drawing the draw Image argument at offset (x, y) using the c Composite operation.
func (*Image) CompositeInto ¶
CompositeInto is equivalent to canvas.Composite/c, im, x, y). See Image.Composite for more information.
func (*Image) Convolve ¶
Convolve applies the given convolution kernel to the image. The order parameter must be a non-negative odd number, while the kernel parameter must have either order*order elements or just one element (in the latter case, it's interpreted as having all elements set to that first value).
func (*Image) CropResize ¶
func (*Image) CropToRatio ¶
func (im *Image) CropToRatio(ratio float64, cs CropStrategy) (*Image, error)
func (*Image) Deconstruct ¶
func (*Image) Delay ¶
Delay returns the time this image stays visible in an animation, in 1/100ths of a second. If this image is not part of a sequence of animated images, it returns 0.
func (*Image) DestroyProperties ¶
func (im *Image) DestroyProperties()
DestroyPropertys removes all properties from the image.
func (*Image) Dispose ¶
func (im *Image) Dispose()
Dispose frees the memory associated with the image. If you try to use a disposed image, you'll get undefined behavior. Note that you don't usually need to call Dispose manually. Just before an Image is collected by the GC, its Dispose method will be called for you. However, if you're allocating multiple images in a loop, it's probably better to manually Dispose them as soon as you don't need them anymore, to avoid the temporary memory usage from getting too high. Behind the scenes, Image uses a finalizer to call Dispose. Please, see http://golang.org/pkg/runtime/#SetFinalizer for more information about finalizers.
func (*Image) Encode ¶
Encode writes the image to the given io.Writer, encoding it according to the info parameter. Please, see the Info type for the available encoding options.
func (*Image) EntropyRect ¶
func (*Image) Flatten ¶
Flatten merges a sequence of images. This is useful for combining Photoshop layers into a single image.
func (*Image) Flip ¶
Flip creates a vertical mirror image by reflecting the pixels around the central x-axis.
func (*Image) FloatMatrix ¶
func (im *Image) FloatMatrix() (FloatMatrix, error)
FloatMatrix returns an Image in the GRAY colorspace as FloatMatrix, where each pixel represents an element of the matrix. Each element is normalized to the [0,1] range.
func (*Image) Flop ¶
Flop creates a horizontal mirror image by reflecting the pixels around the central y-axis.
func (*Image) FrameIndex ¶
func (*Image) Func ¶
Func calls the given C.ImageFunc, which expects a sequence of images rather than a single frame and results the result as a new Image.
func (*Image) GifEncode ¶
GifEncode encodes the Image as GIF using giflib rather than ImageMagick or GraphicksMagick. While this will result in a lower quality GIF, encoding is 9-10x faster and produces files ~20% smaller.
func (*Image) GoImage ¶
GoImage returns the image converted to an RGBA image.Image. Note that since the in-memory representation is different, the conversion could introduce small errors due to rounding in semitransparent pixels, because Go uses premultiplied alpha while GM/IM does not.
func (*Image) HasProperty ¶
HasProperty returns wheter the image has a property with the given key, even if it's set to an empty string.
func (*Image) Image ¶
Image returns the underlying *C.Image. This is useful for calling GM or IM directly and performing operations which are not yet supported by magick.
func (*Image) ImportChannel ¶
ImportChannel imports the given channel from the src image.
func (*Image) Magnify ¶
Magnify is a convenience method that scales an image proportionally to twice its size.
func (*Image) MatteColor ¶
MatteColor returns the image matter color.
func (*Image) Minify ¶
Minify is a convenience method that scales an image proportionally to half its size.
func (*Image) OperateChannel ¶
Operate applies the selected operator to the selected channel(s) of the image. The image is modified and only errors are returned. This method works only on single images, so if you're working with animations you must perform the coalescing and then apply the operator to each frame. See the Operator type for the available operations.
func (*Image) PHash ¶
PHash returns a perceptual hash of the image. The algorithm is based on the pHash library and works as follows:
1 - Transform the image to grayscale. 2 - Apply convolution using a (7, []float64{1}) kernel. 3 - Scale to 32x32. 4 - Compute the DCT for the image. 5 - Grab the 8x8 submatrix starting at (1, 1). 6 - Unroll the matrix by the x axis into an array. 7 - Compute the median for the previous array. 8 - Generate a 64bit hash, where bit x = 1 iff array[x] > median.
Note that due to differences in scaling and convolution algorithms, this function will generate different values for the same image depending on the backend library (IM or GM).
func (*Image) Pixel ¶
Pixel returns a pixel from the image at the given (x, y). coordinates. Note that modifications to the returned Pixel won't alter the image. Use SetPixel to change a pixel in the image.
func (*Image) Pixels ¶
Pixels returns the image pixels contained in the given rect, in row major order. Note that modifications to the returned pixels won't alter the image. Use SetPixels to change pixels in the image.
func (*Image) Properties ¶
Properties returns the keys of the properties that the image contains.
func (*Image) Property ¶
Property returns the property value assocciated with the given key. Note that both non-present keys and keys set to "" will return an empty string. To check if an image has a property defined use Image.HasProperty.
func (*Image) Rect ¶
Rect is a conveniency function which returns a Rect at (0, 0) with the image dimensions.
func (*Image) RemoveFirst ¶
func (*Image) RemoveIndex ¶
func (*Image) RemoveLast ¶
func (*Image) RemoveProperty ¶
RemoveProperty removes the property specified by key.
func (*Image) ResizeBlur ¶
ResizeBlur returns a new image resized to the given dimensions using the provided filter and blur factor (where > 1 is blurry, < 1 is sharp). If width or height is < 0, it's calculated proportionally to the other dimension. If both of them are < 0, an error is returned.
func (*Image) Sample ¶
Sample scales an image to the desired dimensions with pixel sampling. Unlike other scaling methods, this method does not introduce any additional color into the scaled image.
func (*Image) SetBackgroundColor ¶
SetBackgroundColor changes the image background color.
func (*Image) SetBorderColor ¶
SetBorderColor changes the image border color.
func (*Image) SetChannelDepth ¶
SetChannelDepth sets the depth of the channel. The range of depth is 1 to QuantumDepth.
func (*Image) SetColorspace ¶
func (im *Image) SetColorspace(cs Colorspace)
SetColorspace changes the image colorspace. Note that this only changes how the pixels are interpreted. If you want to transform the image to another colorspace use TransformColorspace().
func (*Image) SetMatteColor ¶
SetMatteColor changes the image matte color.
func (*Image) SetPixels ¶
SetPixels changes the pixels in the given rect, in row major order. Note that the number of elements in p must match r.Width * r.Height, otherwise an error is returned.
func (*Image) SetProperty ¶
SetProperty adds a new property to the image. If the property already exists, it's overwritten. Returns true if the property could be added to the list, false otherwise. For removing a property, see Image.RemoveProperty.
func (*Image) Signature ¶
Signature computes a message digest from an image pixel stream with an implementation of the NIST SHA-256 Message Digest algorithm. This signature uniquely identifies the image and is convenient for determining if an image has been modified or whether two images are identical.
func (*Image) Statistics ¶
func (im *Image) Statistics() (*Statistics, error)
func (*Image) Thumbnail ¶
Thumbnail changes the size of an image to the given dimensions. This method was designed by Bob Friesenhahn as a low cost thumbnail generator.
func (*Image) ToChannelImage ¶
ToChannelImage works like ChannelImage, but modifies the image in place.
func (*Image) ToColorspace ¶
func (im *Image) ToColorspace(cs Colorspace) error
ToColorspace changes the image colorspace in place.
func (*Image) TransformColorspace ¶
func (im *Image) TransformColorspace(cs Colorspace) (*Image, error)
TransformColorspace returns a new image by covnerting the original to the given colorspace while also changing the pixels to represent the same image in the new colorspace.
type Info ¶
type Info struct {
// contains filtered or unexported fields
}
Info is used to specify the encoding parameters like format and quality when encoding and image.
func NewInfo ¶
func NewInfo() *Info
NewInfo returns a newly allocated *Info structure. Do not create Info objects directly, since they need to allocate some internal structures while being created.
func (*Info) Colorspace ¶
func (in *Info) Colorspace() Colorspace
Colorspace returns the colorspace used when encoding the image.
func (*Info) Quality ¶
Quality returns the quality used when compressing the image. This parameter does not affect all formats.
func (*Info) SetColorspace ¶
func (in *Info) SetColorspace(cs Colorspace)
SetColorspace set the colorspace used when encoding the image. Note that not all colorspaces are supported for encoding. See the documentation on Colorspace.
func (*Info) SetFormat ¶
SetFormat sets the image format for encoding this image. See http://www.graphicsmagick.org for a list of supported formats.
func (*Info) SetQuality ¶
SetQuality sets the quality used when compressing the image. This parameter does not affect all formats.
type Operator ¶
type Operator int
Operator represents an operation to be applied on all the pixels of the selected channel(s) of an image.
const ( OpAdd Operator = iota + 1 /* Add value */ OpAnd /* Bitwise AND value */ OpAssign /* Direct value assignment */ OpDepth /* Divide by value */ OpDivide /* Bitwise left-shift value N bits */ OpGamma /* Adjust image gamma */ OpLog /* log(quantum*value+1)/log(value+1) */ OpLShift /* Bitwise left-shift value N bits */ OpMax /* Assign value if > quantum */ OpMin /* Assign value if < quantum */ OpMultiply /* Multiply by value */ OpNegate /* Negate channel, ignore value */ OpGaussianNoise /* Gaussian noise */ OpImpulseNoise /* Impulse noise */ OpLaplacianNoise /* Laplacian noise */ OpMultiplicativeNoise /* Multiplicative gaussian noise */ OpPoissonNoise /* Poisson noise */ OpRandomNoise /* Random noise */ OpUniformNoise /* Uniform noise */ OpOr /* Bitwise OR value */ OpPow /* Power function: pow(quantum,value) */ OpRShift /* Bitwise right shift value */ OpSubstract /* Subtract value */ OpThresholdBlack /* Below threshold is black */ OpThreshold /* Above threshold white, otherwise black */ OpThresholdWhite /* Above threshold is white */ OpXor /* Bitwise XOR value */ )
type PHash ¶
type PHash uint64
PHash represents a perceptual hash. Use Image.PHash() to obtain the perceptual hash of an image.
type Pixel ¶
type Pixel struct { Red uint8 Green uint8 Blue uint8 Opacity uint8 // 0 means fully opaque, 255 means fully transparent }
Pixel represents a color identified by its red, green, blue and alpha components. Their value goes from 0 to 255.
type Statistics ¶
type Statistics struct { Red *ChannelStatistics Green *ChannelStatistics Blue *ChannelStatistics Opacity *ChannelStatistics }
type Storage ¶
type Storage C.StorageType
Source Files ¶
- bridge.go
- channel.go
- channel_im.go
- color.go
- color_im.go
- colorspace.go
- colorspace_im.go
- compare.go
- compat.go
- composite.go
- composite_im.go
- constitute.go
- decorate.go
- effect.go
- errors.go
- gen_strings.go
- geom.go
- gif.go
- image.go
- info.go
- list.go
- magick.go
- magick_im.go
- matrix.go
- operator.go
- operator_im.go
- optimize.go
- phash.go
- pixel.go
- pixel_im.go
- properties.go
- properties_im.go
- ref.go
- refcount.go
- resize.go
- shear.go
- signature.go
- statistics.go
- statistics_im.go
- transform.go
- util.go
- util_c.go