Index | Files | Directories

package images

import ""


Package Files


func Decode Uses

func Decode(r io.Reader, opts *DecodeOpts) (image.Image, Config, error)

Decode decodes an image from r using the provided decoding options. The Config returned is similar to the one from the image package, with the addition of the Modified field which indicates if the image was actually flipped, rotated, or scaled. If opts is nil, the defaults are used.

func ScaledDimensions Uses

func ScaledDimensions(w, h, mw, mh int) (newWidth int, newHeight int)

ScaledDimensions returns the newWidth and newHeight obtained when an image of dimensions w x h has to be rescaled under mw x mh, while conserving the proportions. It returns 1,1 if any of the parameter is 0.

func ThumbnailVersion Uses

func ThumbnailVersion() string

ThumbnailVersion returns a string safe for URL query components which is a generation number. Whenever the thumbnailing code is updated, so will this string. It should be placed in some URL component (typically "tv").

type Config Uses

type Config struct {
    Width, Height int
    Format        string
    Modified      bool // true if Decode actually rotated or flipped the image.

Config is like the standard library's image.Config as used by DecodeConfig.

func DecodeConfig Uses

func DecodeConfig(r io.Reader) (Config, error)

DecodeConfig returns the image Config similarly to the standard library's image.DecodeConfig with the addition that it also checks for an EXIF orientation, and sets the Width and Height as they would visibly be after correcting for that orientation.

type DecodeOpts Uses

type DecodeOpts struct {
    // Rotate specifies how to rotate the image.
    // If nil, the image is rotated automatically based on EXIF metadata.
    // If an int, Rotate is the number of degrees to rotate
    // counter clockwise and must be one of 0, 90, -90, 180, or
    // -180.
    Rotate interface{}

    // Flip specifies how to flip the image.
    // If nil, the image is flipped automatically based on EXIF metadata.
    // Otherwise, Flip is a FlipDirection bitfield indicating how to flip.
    Flip interface{}

    // MaxWidgth and MaxHeight optionally specify bounds on the
    // image's size. Rescaling is done before flipping or rotating.
    // Proportions are conserved, so the smallest of the two is used
    // as the decisive one if needed.
    MaxWidth, MaxHeight int

    // ScaleWidth and ScaleHeight optionally specify how to rescale the
    // image's dimensions. Rescaling is done before flipping or rotating.
    // Proportions are conserved, so the smallest of the two is used
    // as the decisive one if needed.
    // They overrule MaxWidth and MaxHeight.
    ScaleWidth, ScaleHeight float32

type FlipDirection Uses

type FlipDirection int

The FlipDirection type is used by the Flip option in DecodeOpts to indicate in which direction to flip an image.

const (
    FlipVertical FlipDirection = 1 << iota

FlipVertical and FlipHorizontal are two possible FlipDirections values to indicate in which direction an image will be flipped.


fastjpegPackage fastjpeg uses djpeg(1), from the Independent JPEG Group's ( jpeg package, to quickly down-sample images on load.
resizePackage resize resizes images.

Package images imports 17 packages (graph) and is imported by 94 packages. Updated 2018-01-15. Refresh now. Tools for package owners.