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 ¶
- type Image
- func (i *Image) CleanupResources()
- func (i *Image) DecodeImage() (image.Image, error)
- func (i *Image) GetHeight() int
- func (i *Image) GetLevels() int
- func (i *Image) GetTileHeight() int
- func (i *Image) GetTileWidth() int
- func (i *Image) GetWidth() int
- func (i *Image) Image() (image.Image, error)
- func (i *Image) SetCrop(r image.Rectangle)
- func (i *Image) SetResizeWH(width, height int)
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 ¶
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 ¶
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) GetLevels ¶
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 ¶
GetTileHeight returns 0 since images using this library have no tiles
func (*Image) GetTileWidth ¶
GetTileWidth returns 0 since images using this library have no tiles
func (*Image) Image ¶
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) SetResizeWH ¶
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.