magick: github.com/rainycape/magick Index | Files

package magick

import "github.com/rainycape/magick"

Index

Package 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

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")
)

func Backend Uses

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 Uses

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 Uses

func QuantumRange() uint64

QuantumRange returns the maximum value representable by the current QuantumDepth (= pow(2, QuantumDepth) - 1).

func SupportedFormats Uses

func SupportedFormats() ([]string, error)

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.

type AffineMatrix Uses

type AffineMatrix struct {
    Sx, Sy, Rx, Ry, Tx, Ty float64
}

type Channel Uses

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 Uses

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 Uses

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 Uses

func (c Colorspace) String() string

type Composite Uses

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
)

func (Composite) String Uses

func (c Composite) String() string

type CropStrategy Uses

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 Uses

type ErrorStats struct {
    MeanPerPixel      float64
    NormalizedMean    float64
    NormalizedMaximum float64
}

ErrorStats represents the difference between two compared images.

func (*ErrorStats) IsZero Uses

func (stats *ErrorStats) IsZero() bool

IsZero returns true iff the two compared images are equal.

type Filter Uses

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
)

func (Filter) String Uses

func (f Filter) String() string

type FloatMatrix Uses

type FloatMatrix [][]float64

func NewDCTMatrix Uses

func NewDCTMatrix(order int) FloatMatrix

func NewFloatMatrix Uses

func NewFloatMatrix(rows int, columns int) FloatMatrix

func (FloatMatrix) Columns Uses

func (m FloatMatrix) Columns() int

func (FloatMatrix) Multiply Uses

func (m FloatMatrix) Multiply(n FloatMatrix) (FloatMatrix, error)

func (FloatMatrix) Rows Uses

func (m FloatMatrix) Rows() int

func (FloatMatrix) SubMatrix Uses

func (m FloatMatrix) SubMatrix(x int, y int, rows int, columns int) (FloatMatrix, error)

func (FloatMatrix) Transposed Uses

func (m FloatMatrix) Transposed() FloatMatrix

func (FloatMatrix) UnrollX Uses

func (m FloatMatrix) UnrollX() []float64

UnrollX returns all values in a slice which contains all rows in increasing order.

func (FloatMatrix) UnrollY Uses

func (m FloatMatrix) UnrollY() []float64

UnrollX returns all values in a slice which contains all columns in increasing order.

type Frame Uses

type Frame struct {
    X          int
    Y          int
    Width      uint
    Height     uint
    InnerBevel int
    OuterBevel int
}

type Histogram Uses

type Histogram struct {
    Items []*HistogramItem
}

type HistogramItem Uses

type HistogramItem struct {
    Color *Pixel
    Count int
}

type Image Uses

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 Uses

func Constitute(width int, height int, channels string, st Storage, pixels []byte) (*Image, error)

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 Uses

func Decode(r io.Reader) (*Image, error)

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 Uses

func DecodeData(data []byte) (*Image, error)

DecodeData works like Decode, but accepts a []byte rather than an io.Reader.

func DecodeFile Uses

func DecodeFile(filename string) (*Image, error)

DecodeFile works like Decode, but accepts a filename.

func New Uses

func New(width int, height int) (*Image, error)

New returns a new RGBA image with the given size. If you need more granularity, see Constitute.

func (*Image) AddBorder Uses

func (im *Image) AddBorder(r Rect, c *Pixel) (*Image, error)

func (*Image) AddFrame Uses

func (im *Image) AddFrame(f Frame, c *Pixel) (*Image, error)

func (*Image) AffineTransform Uses

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) Append Uses

func (im *Image) Append(image *Image) error

func (*Image) Apply Uses

func (im *Image) Apply(f func(*Image) (*Image, error)) (*Image, error)

func (*Image) ApplyDataFunc Uses

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 Uses

func (im *Image) ApplyFunc(f C.ImageFunc) (*Image, error)

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 Uses

func (im *Image) ApplyRectFunc(f C.ImageDataFunc, r Rect) (*Image, error)

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 Uses

func (im *Image) AverageColor() (*Pixel, error)

AverageColor returns the image's average color as a *Pixel.

func (*Image) BackgroundColor Uses

func (im *Image) BackgroundColor() *Pixel

BackgroundColor returns the image background color.

func (*Image) BorderColor Uses

func (im *Image) BorderColor() *Pixel

BorderColore returns the image border color.

func (*Image) ChannelDepth Uses

func (im *Image) ChannelDepth(ch Channel) (uint, error)

ChannelDepth returns the depth of the given channel.

func (*Image) ChannelImage Uses

func (im *Image) ChannelImage(ch Channel) (*Image, error)

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) Chop Uses

func (im *Image) Chop(r Rect) (*Image, error)

func (*Image) Clone Uses

func (im *Image) Clone() (*Image, error)

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 Uses

func (im *Image) Coalesce() (*Image, error)

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 Uses

func (im *Image) Colorspace() Colorspace

Colorspace returns the image colorspace.

func (*Image) Compare Uses

func (im *Image) Compare(src *Image) (*ErrorStats, error)

Compare returns comparison of two images as an ErrorStatus. See also IsEqual.

func (*Image) Composite Uses

func (im *Image) Composite(c Composite, draw *Image, x int, y int) error

Composite modifies the image, drawing the draw Image argument at offset (x, y) using the c Composite operation.

func (*Image) CompositeInto Uses

func (im *Image) CompositeInto(c Composite, canvas *Image, x int, y int) error

CompositeInto is equivalent to canvas.Composite/c, im, x, y). See Image.Composite for more information.

func (*Image) Convolve Uses

func (im *Image) Convolve(order int, kernel []float64) (*Image, error)

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) Crop Uses

func (im *Image) Crop(r Rect) (*Image, error)

func (*Image) CropResize Uses

func (im *Image) CropResize(width, height int, filter Filter, cs CropStrategy) (*Image, error)

func (*Image) CropToRatio Uses

func (im *Image) CropToRatio(ratio float64, cs CropStrategy) (*Image, error)

func (*Image) Deconstruct Uses

func (im *Image) Deconstruct() (*Image, error)

func (*Image) Delay Uses

func (im *Image) Delay() int

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) Depth Uses

func (im *Image) Depth() int

Depth returns the pixel depth of the image, usually 8.

func (*Image) DestroyProperties Uses

func (im *Image) DestroyProperties()

DestroyPropertys removes all properties from the image.

func (*Image) Dispose Uses

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) Duration Uses

func (im *Image) Duration() int

func (*Image) Encode Uses

func (im *Image) Encode(w io.Writer, info *Info) error

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) Entropy Uses

func (im *Image) Entropy() float32

func (*Image) EntropyRect Uses

func (im *Image) EntropyRect(r Rect) float32

func (*Image) Extent Uses

func (im *Image) Extent(r Rect) (*Image, error)

func (*Image) First Uses

func (im *Image) First() *Image

func (*Image) Flatten Uses

func (im *Image) Flatten() (*Image, error)

Flatten merges a sequence of images. This is useful for combining Photoshop layers into a single image.

func (*Image) Flip Uses

func (im *Image) Flip() (*Image, error)

Flip creates a vertical mirror image by reflecting the pixels around the central x-axis.

func (*Image) FloatMatrix Uses

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 Uses

func (im *Image) Flop() (*Image, error)

Flop creates a horizontal mirror image by reflecting the pixels around the central y-axis.

func (*Image) Format Uses

func (im *Image) Format() string

Format returns the format used to decode this image.

func (*Image) Frame Uses

func (im *Image) Frame(idx int) (*Image, error)

func (*Image) FrameIndex Uses

func (im *Image) FrameIndex() int

func (*Image) Func Uses

func (im *Image) Func(f C.ImageFunc) (*Image, error)

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 Uses

func (im *Image) GifEncode() ([]byte, error)

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 Uses

func (im *Image) GoImage() (image.Image, error)

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 Uses

func (im *Image) HasProperty(key string) bool

HasProperty returns wheter the image has a property with the given key, even if it's set to an empty string.

func (*Image) Height Uses

func (im *Image) Height() int

Height returns the image height in pixels.

func (*Image) Histogram Uses

func (im *Image) Histogram() (*Histogram, error)

func (*Image) Image Uses

func (im *Image) Image() *C.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 Uses

func (im *Image) ImportChannel(src *Image, ch Channel) error

ImportChannel imports the given channel from the src image.

func (*Image) IsEqual Uses

func (im *Image) IsEqual(src *Image) (bool, error)

IsEqual returns wheter two images are equal. See also Compare.

func (*Image) IsOrphan Uses

func (im *Image) IsOrphan() bool

func (*Image) IsPalette Uses

func (im *Image) IsPalette() (bool, error)

func (*Image) Last Uses

func (im *Image) Last() *Image

func (*Image) Magnify Uses

func (im *Image) Magnify() (*Image, error)

Magnify is a convenience method that scales an image proportionally to twice its size.

func (*Image) MatteColor Uses

func (im *Image) MatteColor() *Pixel

MatteColor returns the image matter color.

func (*Image) Minify Uses

func (im *Image) Minify() (*Image, error)

Minify is a convenience method that scales an image proportionally to half its size.

func (*Image) Mosaic Uses

func (im *Image) Mosaic() (*Image, error)

func (*Image) NColors Uses

func (im *Image) NColors() (int, error)

func (*Image) NFrames Uses

func (im *Image) NFrames() int

func (*Image) Next Uses

func (im *Image) Next() *Image

func (*Image) Operate Uses

func (im *Image) Operate(op Operator, value float64) error

Operate is a shorthand for OperateChannel(op, CAll, value).

func (*Image) OperateChannel Uses

func (im *Image) OperateChannel(op Operator, ch Channel, value float64) error

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 Uses

func (im *Image) PHash() (PHash, error)

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 Uses

func (im *Image) Pixel(x int, y int) (*Pixel, error)

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 Uses

func (im *Image) Pixels(r Rect) ([]*Pixel, error)

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) Prepend Uses

func (im *Image) Prepend(image *Image) error

func (*Image) Prev Uses

func (im *Image) Prev() *Image

func (*Image) Properties Uses

func (im *Image) Properties() []string

Properties returns the keys of the properties that the image contains.

func (*Image) Property Uses

func (im *Image) Property(key string) string

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) Raise Uses

func (im *Image) Raise(r Rect, threedimensional bool) (*Image, error)

func (*Image) Rect Uses

func (im *Image) Rect() Rect

Rect is a conveniency function which returns a Rect at (0, 0) with the image dimensions.

func (*Image) Remove Uses

func (im *Image) Remove() bool

func (*Image) RemoveFirst Uses

func (im *Image) RemoveFirst() bool

func (*Image) RemoveIndex Uses

func (im *Image) RemoveIndex(idx int) bool

func (*Image) RemoveLast Uses

func (im *Image) RemoveLast() bool

func (*Image) RemoveProperty Uses

func (im *Image) RemoveProperty(key string) bool

RemoveProperty removes the property specified by key.

func (*Image) Resize Uses

func (im *Image) Resize(width, height int, filter Filter) (*Image, error)

Resize works like ResizeBlur, but sets the blur to 1

func (*Image) ResizeBlur Uses

func (im *Image) ResizeBlur(width, height int, filter Filter, blur float64) (*Image, error)

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) Reverse Uses

func (im *Image) Reverse()

func (*Image) Roll Uses

func (im *Image) Roll(xoffset, yoffset int) (*Image, error)

func (*Image) Sample Uses

func (im *Image) Sample(width, height int) (*Image, error)

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) Scale Uses

func (im *Image) Scale(width, height int) (*Image, error)

Scale changes the size of an image to the given dimensions.

func (*Image) SetBackgroundColor Uses

func (im *Image) SetBackgroundColor(px *Pixel)

SetBackgroundColor changes the image background color.

func (*Image) SetBorderColor Uses

func (im *Image) SetBorderColor(px *Pixel)

SetBorderColor changes the image border color.

func (*Image) SetChannelDepth Uses

func (im *Image) SetChannelDepth(ch Channel, depth uint) error

SetChannelDepth sets the depth of the channel. The range of depth is 1 to QuantumDepth.

func (*Image) SetColorspace Uses

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 Uses

func (im *Image) SetMatteColor(px *Pixel)

SetMatteColor changes the image matte color.

func (*Image) SetPixel Uses

func (im *Image) SetPixel(x int, y int, p *Pixel) error

SetPixel changes the pixel at the given (x, y) coordinates.

func (*Image) SetPixels Uses

func (im *Image) SetPixels(r Rect, p []*Pixel) error

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 Uses

func (im *Image) SetProperty(key string, value string) bool

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) Shave Uses

func (im *Image) Shave(r Rect) (*Image, error)

func (*Image) Signature Uses

func (im *Image) Signature() string

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 Uses

func (im *Image) Statistics() (*Statistics, error)

func (*Image) Thumbnail Uses

func (im *Image) Thumbnail(width, height int) (*Image, error)

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 Uses

func (im *Image) ToChannelImage(ch Channel) error

ToChannelImage works like ChannelImage, but modifies the image in place.

func (*Image) ToColorspace Uses

func (im *Image) ToColorspace(cs Colorspace) error

ToColorspace changes the image colorspace in place.

func (*Image) Transform Uses

func (im *Image) Transform(crop, image string) *Image

func (*Image) TransformColorspace Uses

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.

func (*Image) Width Uses

func (im *Image) Width() int

Width returns the image width in pixels.

type Info Uses

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 Uses

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 Uses

func (in *Info) Colorspace() Colorspace

Colorspace returns the colorspace used when encoding the image.

func (*Info) Format Uses

func (in *Info) Format() string

Format returns the format used for encoding the image.

func (*Info) Quality Uses

func (in *Info) Quality() uint

Quality returns the quality used when compressing the image. This parameter does not affect all formats.

func (*Info) SetColorspace Uses

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 Uses

func (in *Info) SetFormat(format string)

SetFormat sets the image format for encoding this image. See http://www.graphicsmagick.org for a list of supported formats.

func (*Info) SetQuality Uses

func (in *Info) SetQuality(q uint)

SetQuality sets the quality used when compressing the image. This parameter does not affect all formats.

type Operator Uses

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 */
)

func (Operator) String Uses

func (o Operator) String() string

type Optimizer Uses

type Optimizer func([]byte) ([]byte, error)

type PHash Uses

type PHash uint64

PHash represents a perceptual hash. Use Image.PHash() to obtain the perceptual hash of an image.

func (PHash) Compare Uses

func (p PHash) Compare(q PHash) float64

Compare returns a number between in the [0,1] interval. The difference is calculated as number of different bits / 64. This means 0 indicates that the hashes are equal, while 1 indicates that the hashes have no bits in common.

func (PHash) String Uses

func (p PHash) String() string

func (PHash) Uint64 Uses

func (p PHash) Uint64() uint64

type Pixel Uses

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.

func (*Pixel) String Uses

func (p *Pixel) String() string

type Rect Uses

type Rect struct {
    X      int
    Y      int
    Width  uint
    Height uint
}

type Statistics Uses

type Statistics struct {
    Red     *ChannelStatistics
    Green   *ChannelStatistics
    Blue    *ChannelStatistics
    Opacity *ChannelStatistics
}

type Storage Uses

type Storage C.StorageType

Package magick imports 17 packages (graph) and is imported by 3 packages. Updated 2018-03-06. Refresh now. Tools for package owners.