magick

package
v2.9.1+incompatible Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 2, 2018 License: CC0-1.0 Imports: 7 Imported by: 0

Documentation

Overview

Package magick is a hacked up port of the minimal functionality we need to satisfy the IIIFImageDecoder interface. Code is based in part on github.com/quirkey/magick

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Image

type Image struct {
	// contains filtered or unexported fields
}

Image implements IIIFImageDecoder for reading non-JP2 image types via image magick bindings. Requires ImageMagick dev files to be installed.

NOTE: To keep with the IIIFImageDecoder interface, we're not really using ImageMagick efficiently. We don't let it rotate, change color depth, encode, etc. We instead convert to a Go image, which is itself probably slow, and then let even less efficient code take over for those operations.

func NewImage

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

NewImage reads the header data from the given file and sets up various ImageMagick data structures, returning a valid Image instance.

func (*Image) CleanupResources

func (i *Image) CleanupResources()

CleanupResources frees the C data allocated by ImageMagick

func (*Image) DecodeImage

func (i *Image) DecodeImage() (image.Image, error)

DecodeImage returns an image.Image that holds the decoded image data, resized and cropped if resizing or cropping was requested. Both cropping and resizing happen here due to the nature of openjpeg and our desire to keep this API consistent with the jp2 api.

func (*Image) GetHeight

func (i *Image) GetHeight() int

GetHeight returns the Height of the loaded image in pixels as an int

func (*Image) GetLevels

func (i *Image) GetLevels() int

GetLevels returns 1 since images here cannot be multi-resolution, and therefore always have just a single resolution. If we ever support pyramidal TIFFs, those will need a separate implementation.

func (*Image) GetTileHeight

func (i *Image) GetTileHeight() int

GetTileHeight returns 0 since images using this library have no tiles

func (*Image) GetTileWidth

func (i *Image) GetTileWidth() int

GetTileWidth returns 0 since images using this library have no tiles

func (*Image) GetWidth

func (i *Image) GetWidth() int

GetWidth returns the Width of the loaded image in pixels as an int

func (*Image) Image

func (i *Image) Image() (image.Image, error)

Image returns a native Go image interface. For now, this is always RGBA for simplicity, but it would be a good idea to use a gray image when it makes sense to improve performance and RAM usage.

func (*Image) SetCrop

func (i *Image) SetCrop(r image.Rectangle)

SetCrop sets the image to crop to the given rectangle

func (*Image) SetResizeWH

func (i *Image) SetResizeWH(width, height int)

SetResizeWH sets the image to scale to the given width and height. If one dimension is 0, the decoded image will preserve the aspect ratio while scaling to the non-zero dimension.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL