goheif

package module
v0.0.0-...-168724e Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

README

goheif

go heif

Documentation

Index

Constants

View Source
const (
	CompressionUndefined = C.heif_compression_undefined
	CompressionHEVC      = C.heif_compression_HEVC
	CompressionAV1       = C.heif_compression_AV1
	CompressionAVC       = C.heif_compression_AVC
	CompressionJPEG      = C.heif_compression_JPEG
)
View Source
const (
	ChromaUndefined              = C.heif_chroma_undefined
	ChromaMonochrome             = C.heif_chroma_monochrome
	Chroma420                    = C.heif_chroma_420
	Chroma422                    = C.heif_chroma_422
	Chroma444                    = C.heif_chroma_444
	ChromaInterleavedRGB         = C.heif_chroma_interleaved_RGB
	ChromaInterleavedRGBA        = C.heif_chroma_interleaved_RGBA
	ChromaInterleavedRRGGBBAA_BE = C.heif_chroma_interleaved_RRGGBBAA_BE
	ChromaInterleavedRRGGBBAA_LE = C.heif_chroma_interleaved_RRGGBBAA_LE
	ChromaInterleavedRRGGBB_BE   = C.heif_chroma_interleaved_RRGGBB_BE
	ChromaInterleavedRRGGBB_LE   = C.heif_chroma_interleaved_RRGGBB_LE

	ChromaInterleaved24Bit = C.heif_chroma_interleaved_24bit
	ChromaInterleaved32Bit = C.heif_chroma_interleaved_32bit
)
View Source
const (
	ColorspaceUndefined  = C.heif_colorspace_undefined
	ColorspaceYCbCr      = C.heif_colorspace_YCbCr
	ColorspaceRGB        = C.heif_colorspace_RGB
	ColorspaceMonochrome = C.heif_colorspace_monochrome
)
View Source
const (
	ChannelY           = C.heif_channel_Y
	ChannelCb          = C.heif_channel_Cb
	ChannelCr          = C.heif_channel_Cr
	ChannelR           = C.heif_channel_R
	ChannelG           = C.heif_channel_G
	ChannelB           = C.heif_channel_B
	ChannelAlpha       = C.heif_channel_Alpha
	ChannelInterleaved = C.heif_channel_interleaved
)
View Source
const (
	ProgressStepTotal    = C.heif_progress_step_total
	ProgressStepLoadTile = C.heif_progress_step_load_tile
)
View Source
const (
	ErrorOK = C.heif_error_Ok

	// Input file does not exist.
	ErrorInputDoesNotExist = C.heif_error_Input_does_not_exist

	// Input file type is not supported.
	ErrorUnsupportedFiletype = C.heif_error_Unsupported_filetype

	// Image requires an unsupported decoder feature.
	ErrorUnsupportedFeature = C.heif_error_Unsupported_feature

	// Library API has been used in an invalid way.
	ErrorUsage = C.heif_error_Usage_error

	// Could not allocate enough memory.
	ErrorMemoryAllocation = C.heif_error_Memory_allocation_error

	// The decoder plugin generated an error
	ErrorDecoderPlugin = C.heif_error_Decoder_plugin_error

	// The decoder plugin generated an error
	ErrorEncoderPlugin = C.heif_error_Encoder_plugin_error

	// Error during encoding or when writing to the output
	ErrorEncoding = C.heif_error_Encoding_error

	// Application has asked for a color profile type that does not exist
	ErrorColorProfileDoesNotExist = C.heif_error_Color_profile_does_not_exist
)
View Source
const (
	// no further information available
	SuberrorUnspecified = C.heif_suberror_Unspecified

	// End of data reached unexpectedly.
	SuberrorEndOfData = C.heif_suberror_End_of_data

	// Size of box (defined in header) is wrong
	SuberrorInvalidBoxSize = C.heif_suberror_Invalid_box_size

	// Mandatory 'ftyp' box is missing
	SuberrorNoFtypBox = C.heif_suberror_No_ftyp_box

	SuberrorNoIdatBox = C.heif_suberror_No_idat_box

	SuberrorNoMetaBox = C.heif_suberror_No_meta_box

	SuberrorNoHdlrBox = C.heif_suberror_No_hdlr_box

	SuberrorNoHvcCBox = C.heif_suberror_No_hvcC_box

	SuberrorNoPitmBox = C.heif_suberror_No_pitm_box

	SuberrorNoIpcoBox = C.heif_suberror_No_ipco_box

	SuberrorNoIpmaBox = C.heif_suberror_No_ipma_box

	SuberrorNoIlocBox = C.heif_suberror_No_iloc_box

	SuberrorNoIinfBox = C.heif_suberror_No_iinf_box

	SuberrorNoIprpBox = C.heif_suberror_No_iprp_box

	SuberrorNoIrefBox = C.heif_suberror_No_iref_box

	SuberrorNoPictHandler = C.heif_suberror_No_pict_handler

	// An item property referenced in the 'ipma' box is not existing in the 'ipco' container.
	SuberrorIpmaBoxReferencesNonexistingProperty = C.heif_suberror_Ipma_box_references_nonexisting_property

	// No properties have been assigned to an item.
	SuberrorNoPropertiesAssignedToItem = C.heif_suberror_No_properties_assigned_to_item

	// Image has no (compressed) data
	SuberrorNoItemData = C.heif_suberror_No_item_data

	// Invalid specification of image grid (tiled image)
	SuberrorInvalidGridData = C.heif_suberror_Invalid_grid_data

	// Tile-images in a grid image are missing
	SuberrorMissingGridImages = C.heif_suberror_Missing_grid_images

	SuberrorNoAV1CBox = C.heif_suberror_No_av1C_box

	SuberrorInvalidCleanAperture = C.heif_suberror_Invalid_clean_aperture

	// Invalid specification of overlay image
	SuberrorInvalidOverlayData = C.heif_suberror_Invalid_overlay_data

	// Overlay image completely outside of visible canvas area
	SuberrorOverlayImageOutsideOfCanvas = C.heif_suberror_Overlay_image_outside_of_canvas

	SuberrorAuxiliaryImageTypeUnspecified = C.heif_suberror_Auxiliary_image_type_unspecified

	SuberrorNoOrInvalidPrimaryItem = C.heif_suberror_No_or_invalid_primary_item

	SuberrorNoInfeBox = C.heif_suberror_No_infe_box

	SuberrorUnknownColorProfileType = C.heif_suberror_Unknown_color_profile_type

	SuberrorWrongTileImageChromaFormat = C.heif_suberror_Wrong_tile_image_chroma_format

	SuberrorInvalidFractionalNumber = C.heif_suberror_Invalid_fractional_number

	SuberrorInvalidImageSize = C.heif_suberror_Invalid_image_size

	// A security limit preventing unreasonable memory allocations was exceeded by the input file.
	// Please check whether the file is valid. If it is, contact us so that we could increase the
	// security limits further.
	SuberrorSecurityLimitExceeded = C.heif_suberror_Security_limit_exceeded

	// An item ID was used that is not present in the file.
	SuberrorNonexistingItemReferenced = C.heif_suberror_Nonexisting_item_referenced // also used for Invalid_input

	// An API argument was given a NULL pointer, which is not allowed for that function.
	SuberrorNullPointerArgument = C.heif_suberror_Null_pointer_argument

	// Image channel referenced that does not exist in the image
	SuberrorNonexistingImageChannelReferenced = C.heif_suberror_Nonexisting_image_channel_referenced

	// The version of the passed plugin is not supported.
	SuberrorUnsupportedPluginVersion = C.heif_suberror_Unsupported_plugin_version

	// The version of the passed writer is not supported.
	SuberrorUnsupportedWriterVersion = C.heif_suberror_Unsupported_writer_version

	// The given (encoder) parameter name does not exist.
	SuberrorUnsupportedParameter = C.heif_suberror_Unsupported_parameter

	// The value for the given parameter is not in the valid range.
	SuberrorInvalidParameterValue = C.heif_suberror_Invalid_parameter_value

	SuberrorInvalidPixiBox = C.heif_suberror_Invalid_pixi_box

	SuberrorWrongTileImagePixelDepth = C.heif_suberror_Wrong_tile_image_pixel_depth

	// Image was coded with an unsupported compression method.
	SuberrorUnsupportedCodec = C.heif_suberror_Unsupported_codec

	// Image is specified in an unknown way, e.g. as tiled grid image (which is supported)
	SuberrorUnsupportedImageType = C.heif_suberror_Unsupported_image_type

	SuberrorUnsupportedDataVersion = C.heif_suberror_Unsupported_data_version

	// The conversion of the source image to the requested chroma / colorspace is not supported.
	SuberrorUnsupportedColorConversion = C.heif_suberror_Unsupported_color_conversion

	SuberrorUnsupportedItemConstructionMethod = C.heif_suberror_Unsupported_item_construction_method

	SuberrorUnsupportedBitDepth = C.heif_suberror_Unsupported_bit_depth

	SuberrorCannotWriteOutputData = C.heif_suberror_Cannot_write_output_data
)

Variables

This section is empty.

Functions

func Encode

func Encode(w io.Writer, img image.Image, opt ...EncodeOption) error

Encode to heif

func GetVersion

func GetVersion() string

Types

type Channel

type Channel C.enum_heif_channel

type Chroma

type Chroma C.enum_heif_chroma

type Colorspace

type Colorspace C.enum_heif_colorspace

type Context

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

func EncodeFromImage

func EncodeFromImage(img image.Image, compression Compression, quality int, lossless LosslessMode, logging LoggingLevel) (*Context, error)

func NewContext

func NewContext() (*Context, error)

func (*Context) GetImageHandle

func (c *Context) GetImageHandle(id int) (*ImageHandle, error)

func (*Context) GetListOfTopLevelImageIDs

func (c *Context) GetListOfTopLevelImageIDs() []int

func (*Context) GetNumberOfTopLevelImages

func (c *Context) GetNumberOfTopLevelImages() int

func (*Context) GetPrimaryImageHandle

func (c *Context) GetPrimaryImageHandle() (*ImageHandle, error)

func (*Context) GetPrimaryImageID

func (c *Context) GetPrimaryImageID() (int, error)

func (*Context) IsTopLevelImageID

func (c *Context) IsTopLevelImageID(ID int) bool

func (*Context) NewEncoder

func (c *Context) NewEncoder(compression Compression) (*Encoder, error)

func (*Context) ReadFromFile

func (c *Context) ReadFromFile(filename string) error

func (*Context) ReadFromMemory

func (c *Context) ReadFromMemory(data []byte) error

func (*Context) WriteToFile

func (c *Context) WriteToFile(filename string) error

type DecodingOptions

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

func NewDecodingOptions

func NewDecodingOptions() (*DecodingOptions, error)

type EncodeOption

type EncodeOption func(opts *EncodeOptions)

EncodeOption ...

func WithEncodeCompression

func WithEncodeCompression(Compression Compression) EncodeOption

WithEncodeCompression ...

func WithEncodeLoggingLevel

func WithEncodeLoggingLevel(LoggingLevel LoggingLevel) EncodeOption

WithEncodeLoggingLevel ...

func WithEncodeLosslessMode

func WithEncodeLosslessMode(LosslessMode LosslessMode) EncodeOption

WithEncodeLosslessMode ...

func WithEncodeQuality

func WithEncodeQuality(Quality int) EncodeOption

WithEncodeQuality ...

type EncodeOptions

type EncodeOptions struct {
	Quality      int
	Compression  Compression
	LosslessMode LosslessMode
	LoggingLevel LoggingLevel
}

EncodeOptions is heif encode options

type Encoder

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

func (*Encoder) ID

func (e *Encoder) ID() string

func (*Encoder) Name

func (e *Encoder) Name() string

func (*Encoder) SetLoggingLevel

func (e *Encoder) SetLoggingLevel(l LoggingLevel) error

func (*Encoder) SetLossless

func (e *Encoder) SetLossless(l LosslessMode) error

func (*Encoder) SetQuality

func (e *Encoder) SetQuality(q int) error

type EncodingOptions

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

func NewEncodingOptions

func NewEncodingOptions() (*EncodingOptions, error)

type ErrorCode

type ErrorCode C.enum_heif_error_code

type ErrorSubcode

type ErrorSubcode C.enum_heif_suberror_code

type HeifError

type HeifError struct {
	Code    ErrorCode
	Subcode ErrorSubcode
	Message string
}

func (*HeifError) Error

func (e *HeifError) Error() string

type Image

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

func NewImage

func NewImage(width, height int, colorspace Colorspace, chroma Chroma) (*Image, error)

func (*Image) GetBitsPerPixel

func (img *Image) GetBitsPerPixel(channel Channel) int

func (*Image) GetBitsPerPixelRange

func (img *Image) GetBitsPerPixelRange(channel Channel) int

func (*Image) GetChromaFormat

func (img *Image) GetChromaFormat() Chroma

func (*Image) GetColorspace

func (img *Image) GetColorspace() Colorspace

func (*Image) GetHeight

func (img *Image) GetHeight(channel Channel) int

func (*Image) GetImage

func (img *Image) GetImage() (image.Image, error)

func (*Image) GetPlane

func (img *Image) GetPlane(channel Channel) (*ImageAccess, error)

func (*Image) GetWidth

func (img *Image) GetWidth(channel Channel) int

func (*Image) NewPlane

func (img *Image) NewPlane(channel Channel, width, height, depth int) (*ImageAccess, error)

func (*Image) ScaleImage

func (img *Image) ScaleImage(width int, height int) (*Image, error)

type ImageAccess

type ImageAccess struct {
	Plane []byte

	Stride int
	// contains filtered or unexported fields
}

type ImageHandle

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

func (*ImageHandle) DecodeImage

func (h *ImageHandle) DecodeImage(colorspace Colorspace, chroma Chroma, options *DecodingOptions) (*Image, error)

func (*ImageHandle) GetDepthImageHandle

func (h *ImageHandle) GetDepthImageHandle(depth_image_id int) (*ImageHandle, error)

func (*ImageHandle) GetHeight

func (h *ImageHandle) GetHeight() int

func (*ImageHandle) GetListOfDepthImageIDs

func (h *ImageHandle) GetListOfDepthImageIDs() []int

func (*ImageHandle) GetListOfThumbnailIDs

func (h *ImageHandle) GetListOfThumbnailIDs() []int

func (*ImageHandle) GetNumberOfDepthImages

func (h *ImageHandle) GetNumberOfDepthImages() int

func (*ImageHandle) GetNumberOfThumbnails

func (h *ImageHandle) GetNumberOfThumbnails() int

func (*ImageHandle) GetThumbnail

func (h *ImageHandle) GetThumbnail(thumbnail_id int) (*ImageHandle, error)

func (*ImageHandle) GetWidth

func (h *ImageHandle) GetWidth() int

func (*ImageHandle) HasAlphaChannel

func (h *ImageHandle) HasAlphaChannel() bool

func (*ImageHandle) HasDepthImage

func (h *ImageHandle) HasDepthImage() bool

func (*ImageHandle) IsPrimaryImage

func (h *ImageHandle) IsPrimaryImage() bool

type LoggingLevel

type LoggingLevel int
const (
	LoggingLevelNone LoggingLevel = iota
	LoggingLevelBasic
	LoggingLevelAdvanced
	LoggingLevelFull
)

type LosslessMode

type LosslessMode int
const (
	LosslessModeDisabled LosslessMode = iota
	LosslessModeEnabled
)

type ProgressStep

type ProgressStep C.enum_heif_progress_step

Jump to

Keyboard shortcuts

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