Documentation ¶
Index ¶
- Variables
- func Backend() string
- func SupportedFormats() ([]string, error)
- type Channel
- type ChannelStatistics
- type Colorspace
- type Composite
- type CropStrategy
- type Filter
- 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 *Matrix) (*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) 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) 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) 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) 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) 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) 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) SetColorspace(cs Colorspace)
- func (im *Image) SetMatteColor(px *Pixel)
- 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) Transform(crop, image string) *Image
- func (im *Image) TransformColorspace(cs Colorspace) (*Image, error)
- func (im *Image) Width() int
- type Info
- type Matrix
- type Operator
- type Optimizer
- type Pixel
- type Rect
- type Statistics
Constants ¶
This section is empty.
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 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 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 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 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 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 (*Image) AffineTransform ¶
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) 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) 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) 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) 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) 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) 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) 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) 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) TransformColorspace ¶
func (im *Image) TransformColorspace(cs Colorspace) (*Image, error)
TransformColorspace changes the image 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 Pixel ¶
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 }
Source Files ¶
- bridge.go
- channel.go
- color.go
- color_im.go
- colorspace.go
- colorspace_im.go
- compat.go
- composite.go
- composite_im.go
- decorate.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
- pixel.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