Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrHEIC = errors.New("HEIC decoding not implemented yet")
Functions ¶
func HEIFToJPEG ¶
func HEIFToJPEG(fr io.Reader, maxSize *Dimensions) ([]byte, error)
HEIFToJPEG converts the HEIF file in fr to JPEG. It optionally resizes it to the given maxSize argument, if any. It returns the contents of the JPEG file.
func ScaledDimensions ¶
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 ¶
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").
Types ¶
type Config ¶
type Config struct {
Width, Height int
Format string
Modified bool // true if Decode actually rotated or flipped the image.
HEICEXIF []byte // if not nil, the part of the HEIC file that contains EXIF metadata
}
Config is like the standard library's image.Config as used by DecodeConfig.
func Decode ¶
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 DecodeConfig ¶
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 ¶
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 Dimensions ¶
Dimensions is the desired max width and height of an image.
type FlipDirection ¶
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 FlipHorizontal )
FlipVertical and FlipHorizontal are two possible FlipDirections values to indicate in which direction an image will be flipped.
type NoHEICTOJPEGError ¶
type NoHEICTOJPEGError struct {
// contains filtered or unexported fields
}
Directories ¶
Path | Synopsis |
---|---|
Package fastjpeg uses djpeg(1), from the Independent JPEG Group's (www.ijg.org) jpeg package, to quickly down-sample images on load.
|
Package fastjpeg uses djpeg(1), from the Independent JPEG Group's (www.ijg.org) jpeg package, to quickly down-sample images on load. |
Package resize resizes images.
|
Package resize resizes images. |