openjpeg_go

package module
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 12 Imported by: 1

README

openjpeg

golang wrapper for openjpeg library

usage

refer to example dir

import openjpeg "github.com/linxlib/openjpeg"

build

install golang > 1.18 first

Windows

  • install MSYS2
  • add C:\msys64\mingw64\bin to PATH environment
  • open MSYS2 MSYS from start menu, install gcc with pacman -S mingw-w64-x86_64-gcc
  • git clone https://github.com/linxlib/openjpeg
  • cd openjpeg\example
  • go run -v .\main.go
  • then you get a jp2000.jpg in the same dir. you can change the example code to get different image file

Linux (Centos 7)

The version of openjpeg in package manager may not the latest (v2.5.0), so we need to build from source.

build and install openjpeg 2.5.0 (optional)
  • install gcc cmake ...etc
  • wget https://github.com/uclouvain/openjpeg/archive/refs/tags/v2.5.0.zip
  • unzip v2.5.0.zip && cd openjpeg-2.5.0/
  • mkdir build && cd build
  • cmake .. -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS:bool=on
  • make
  • make install
  • you will find openjpeg(libopenjp2) library and in /usr/local/lib /usr/local/include ...
run
  • git clone https://github.com/linxlib/openjpeg
  • cd openjpeg\example
  • go run main.go
  • then you get a jp2000.jpg in the same dir. you can change the example code to get different image file

Mac OS X

May be you don't need to install openjpeg just like linux.

  • configure cgo compile environment by yourself
  • if you have installed ffmpeg, so openjpeg 2.5.0 already installed, just skip the next step
  • brew install openjpeg and make sure opj_decompress -h can get something like openjp2 library v2.5.0
  • git clone https://github.com/linxlib/openjpeg
  • cd openjpeg/example
  • go run main.go
  • then you get a jp2000.jpg in the same dir. you can change the example code to get different image file

Documentation

Index

Constants

View Source
const YCbCrSubsampleRatioUnknown = -1

Variables

This section is empty.

Functions

func Crop

func Crop(i image.Image, rectangle *image.Rectangle) image.Image

func Decode

func Decode(r io.Reader) (img image.Image, err error)

func DecodeConfig

func DecodeConfig(r io.Reader) (cfg image.Config, err error)

func Encode

func Encode(o io.WriteSeeker, img image.Image, opt *Options) (err error)

func GetPixStride

func GetPixStride(i image.Image) ([]byte, int)

func GetSSR

Get sub-sampling ratio if color space has one (0 = no sub-sampling).

func IsGray

func IsGray(img image.Image, fuzz int) bool

func NewImage

func NewImage(c color.Model, r image.Rectangle) image.Image

Create a new Image of specified color model.

func NewImageColorAs

func NewImageColorAs(template image.Image, r image.Rectangle)

Create a new image "in the image" of template, that is, of same color model.

func SSR2VHDiv

func SSR2VHDiv(i image.YCbCrSubsampleRatio) (v, h int)

Translate Go's sub-sampling rate to V/H divisors.

func ToGray

func ToGray(img image.Image, fuzz int) (gr *image.Gray)

Attempt conversion of the input image into greyscale. Fuzz is is a threshold when a color picture is considered greyscale, Higher fuzz will accept more of color variance. If picture is above fuzz, "too colorish", nil is returned. If fuzz threshold is -1, the conversion is done always.

func ToModel

func ToModel(img image.Image, c color.Model) (gr image.Image)

func VHDiv2SSR

func VHDiv2SSR(v, h int) image.YCbCrSubsampleRatio

Translate vertical-horizontal chroma divisors to Go's sub-sampling rate.

Types

type Options

type Options struct {
	BPP          int
	Ratio        []float32
	PSNR         []float32
	NResolutions int
}

type SubImage

type SubImage interface {
	SubImage(r image.Rectangle) image.Image
}

Jump to

Keyboard shortcuts

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